AWS Lambda function for generating HTML for client-side rendered content.
Initially this function was created to be used with WordPress via plugin AWS Lambda Prerender, so you just need to install plugin.
Event JSON:
- Idea of
variableis to use e.g. renderToString from React to render HTML otherwise element's HTML withselectorwill be used. - Secret is for authorization. In WordPress plugin this secret has 20 minutes live time (15 minutes is a maximum execution time of AWS Lambda function and 5 minutes of reserve).
Example:
{
"type": "post",
"id": 345,
"url": "https://www.site.com/blog/hello-world/",
"variable": "prerender",
"selector": "#app",
"return_url": "https://site.com/api/v1/prerender",
"secret": "aQ3qnPPnDwhaB7pzI3Y0jQx*",
"version": "381d3e8bfd139596baf7959fb85b084e"
}
- Use this template from Github.
- Create AWS Access Keys. You can follow this gist to create policy.
- Add API Key & Secret with Region to Github Repository secrets into
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYandAWS_REGIONvariables. - Deploy function with Github Actions.
devbranch will be deployed on push into prerender-dev-render function, production should be deployed manually throughworkflow_dispatchinto prerender-production-render.
