You may want to pre-render HTML pages to serve them / store on your CDN, but need some dynamic content anyway. Time to use some Server Side Includes / Edge Side Includes! This library enables you to use them from React.
On the client (in your browser), an AJAX call will be made to emulate the inclusion.
yarn add react-include
npm install react-include
Server Side Include
Server Side Include are supported by Apache, LiteSpeed, nginx, lighttpd and IIS.
They render as an HTML comment which take this form:
<!--# include ... -->.
;<main><h1>A random quote</h1><SSI virtual="/random/quote" /></main>;
Edge Side Include
Edge Side Include are implemented by Akamai, Fastly, Varnish, Squid and Mongrel
ESI. They render as an HTML tag which takes this form:
<esi:include ... />.
;<main><h1>A random quote</h1><ESI src="/random/quote" /></main>;
string | (required) SSI: the URL you want to include |
string | (required) ESI: the URL you want to include |
string | The wrapper component. Defaults to
| any other | any | Any other prop will be passed to the wrapper |