This repository consists of a sample to demonstrate two variants to do Server Side Rendering with AWS Lambda for React applications. It usues AWS CDK to make the deployment.
This solution can only be provisioned in the us-east-1 Region as it deploys Lambda@Edge, which can only be done in that Region.
Clone git repository
git clone https://github.com/aws-samples/react-ssr-lambda.git
Run the following commands in your terminal window, provide the name of the S3 bucket instead of <your bucket name>
, for example mybucket
, to deploy the static content
cd react-ssr-lambda
cd ./cdk
npm install
npm run build
cdk bootstrap
cdk deploy SSRApiStack --outputs-file ../simple-ssr/src/config.json
cd ../simple-ssr
npm install
npm run build-all
cd ../cdk
cdk deploy SSRAppStack --parameters mySiteBucketName=<your bucket name>
After successful deployment you will see output variables
CF URL - for React App stored on S3 and rendered on client
Lambda SSR URL - for React App rendered by Lambda behind API Gateway
Lambda@Edge SSR URL - for React App rendered by Lambda@Edge
To clean-up the reated resources run
cd ./cdk
cdk destroy SSRApiStack
cdk destroy SSRAppStack