react-amp-components
A (hopefully) simple way to render AMP components via React on the server.
It uses react-helmet for managing all the required meta and script tags.
That means that you can just import and use the AMP component you need, without having to care about adding the additional required script tags.
Warning
This project is still in its early infancy. Only a few components exist, but we will add more. Feel free to contribute :rocket:
Installation
Install it from npm:
or:
Usage
Import and use the AMP component you would like to use:
Then on the server you generate the final HTML output, and the content for the head:
Which you can then interpolate:
AMP Components implemented
amp-sidebar
amp-img
amp-carousel
amp-analytics
amp-accordion
amp-bind
amp-install-serviceworker
amp-ad
Example usage:
Props:
- src (required)
- dataIframeSrc (optional)
- dataNoServiceWorkerFallbackUrlMatch (optional)
- dataNoServiceWorkerFallbackShellUrl (optional)
Todo
- [ ] Define all the AMP components with their properties and scripts in a JSON file and use that to generate them.
- [ ] Rename
Layout
toHelmet
- [ ] Provide helper
finalHTML
renderer