AMP pages for API base system

266 Views Asked by At

We are trying to move our pages to Google AMP for better mobile and SEO experience. Problem is our system is API base totally. We are using nodejs along with react as of now.

Since in AMP you cannot use javascript to make ajax API calls, is there any way to implement to AMP through API's? Searched on the web but not able to find a optimal solution

2

There are 2 best solutions below

2
On

You will need an intermediary http server which makes those API calls and generates static HTML which is served to clients.

0
On

As React and Angular both supports server side rendering. You can use ReactDOMServer.renderToStaticMarkup(element) to generate static html on server while using benefit of react component structure.

  • You can use node server to make API call and pass that data to your React component which will generate AMP html later using renderToStaticMarkup.
  • You can also use redux-connect, npm library which wait for API to resolve on server before rendering react component.