Git Product home page Git Product logo

react-ssr-lambda's Introduction

Sample to deploy React SSR on Lambda

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.

alt

Requirements

  • Node.js 12.x
  • AWS CDK 1.72+
  • Configured aws credentials
  • This example will only be deployed successfuly in us-east-1 region as it is using AWS Lambda@Edge

Folder structure

  • /cdk - code to deploy the solution
  • /simple-ssr - React application created with the create-react-app tool.

Deployment

  • 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

react-ssr-lambda's People

Contributors

amazon-auto avatar dependabot[bot] avatar roman-boiko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.