Git Product home page Git Product logo

react-apig-lambda's Introduction

react-apig-lambda

Render React.js on-demand with CDN caching.

Minimal example on how to render React & React Router v4 with Amazon API Gateway, AWS Lambda and CloudFront.

Online demo

https://test.es6.fi

Basic example app from React Router documentation. Initial server-side render and acts as SPA from there.

Dependencies

Deploying to AWS

  1. Edit project.json and set proper lamdba execution role.

  2. Replace s3://test.es6.fi/assets/ in package.json with your S3 bucket, e.g. s3://your-bucket/assets/.

  3. npm run build to build front-end code

  4. npm run deploy to deploy lambda and upload front build to S3

Setting up API Gateway

  1. In API Gateway home, click Create API

  2. Choose New API and enter some API name, click Create API.

  3. Choose Actions -> Create resource

  4. Check Configure as proxy resource and click Create resource

  5. In /{proxy+} - ANY - Setup, choose Integration type as Lambda Function Proxy, select your lambda's AWS region and enter name of your uploaded lambda function (react-apig-lambda_render-react if you didn't change name in project.json). Click Save.

  6. Choose Actions -> Deploy API, set Deployment stage as [New Stage], enter stage name and click Deploy

  7. Now you should be able to invoke the lambda renderer by navigating to https://your-invoke-url/your-stage-name/index

Setting up CloudFront

  1. Create distribution, paste your API Gateway url as Origin domain name, e.g. https://your-invoke-url/your-stage-name/index. Make sure to include /index.

  2. Set your custom domain in Alternate Domain Names (CNAMEs)

  3. You can leave other settings as they are if you don't want to customize anything, click Create distribution.

  4. Go to your distribution, navigate to Origins, click Create origin

  5. Choose your S3 bucket (you should create it now if you haven't already. Make sure there's assets directory). Click Create.

  6. Go to your distribution, navigate to Behaviors, click Create Behavior.

  7. Set Path Pattern as assets/*, choose your S3 origin and click Create.

  8. In your domain's DNS management interface, point your domain's CNAME to your CloudFront distribution.

react-apig-lambda's People

Contributors

hoppula avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-apig-lambda's Issues

Thoughts on SSR?

Great repo! Have you thought about adding in support for server side rendering? I'd be particularly interested in how to hook that up with apex deployments and API Gateway.

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.