Rendering React with Amazon Lambda
Gerald Monaco
493

One thing to watch out for will be Lambda’s cold start times. For a production app this is usually not acceptable. In my experience this can often be an extra 1–2s. There are workarounds though like setting up a CloudWatch schedule to ping your lambda function every few minutes to keep it hot.

If your React app is largely static you might consider using Lambda to generate the the app and save it to S3 / CloudFront. You can use Lambda to fetch data from your DB or API to generate the initial page load html if you can tolerate serving up cached data.

I wrote a bit about this strategy here: https://hackernoon.com/building-a-static-website-generator-with-react-and-terraform-823be0b24b12

I used a simple schedule to pre-render my React app every 15 minutes but you could also trigger the generator using SNS, S3 or Dynamo.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.