{"id":19180168,"url":"https://github.com/hoppula/react-apig-lambda","last_synced_at":"2025-05-07T22:09:40.618Z","repository":{"id":145962297,"uuid":"69400586","full_name":"hoppula/react-apig-lambda","owner":"hoppula","description":"Render React.js on-demand with CDN caching","archived":false,"fork":false,"pushed_at":"2016-09-27T21:34:33.000Z","size":4,"stargazers_count":93,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T22:09:33.465Z","etag":null,"topics":["api-gateway","aws-lambda","cdn","cloudfront","react","s3-bucket"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoppula.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-27T21:34:06.000Z","updated_at":"2023-03-25T06:58:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"f409bf19-b528-4b35-90c4-12c7fdfa7f53","html_url":"https://github.com/hoppula/react-apig-lambda","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-apig-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-apig-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-apig-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-apig-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoppula","download_url":"https://codeload.github.com/hoppula/react-apig-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961841,"owners_count":21832197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-gateway","aws-lambda","cdn","cloudfront","react","s3-bucket"],"created_at":"2024-11-09T10:48:20.794Z","updated_at":"2025-05-07T22:09:40.598Z","avatar_url":"https://github.com/hoppula.png","language":"JavaScript","readme":"# react-apig-lambda\n\n\u003e Render React.js on-demand with CDN caching.\n\n\u003e Minimal example on how to render React \u0026 React Router v4 with Amazon API Gateway, AWS Lambda and CloudFront.\n\n## Online demo\n[https://test.es6.fi](https://test.es6.fi)\n\nBasic example app from [React Router documentation](https://react-router.now.sh/basic). Initial server-side render and acts as SPA from there.\n\n## Dependencies\n\n* [AWS CLI](https://aws.amazon.com/cli/) for S3 deployment\n* [Apex](https://github.com/apex/apex) for Lambda deployment\n\n## Deploying to AWS\n\n1) Edit `project.json` and set proper lamdba execution `role`.\n\n2) Replace `s3://test.es6.fi/assets/` in `package.json` with your S3 bucket, e.g. `s3://your-bucket/assets/`.\n\n3) `npm run build` to build front-end code\n\n4) `npm run deploy` to deploy lambda and upload front build to S3\n\n## Setting up API Gateway\n\n1) In API Gateway home, click `Create API`\n\n2) Choose `New API` and enter some `API name`, click `Create API`.\n\n2) Choose `Actions -\u003e Create resource`\n\n3) Check `Configure as proxy resource` and click `Create resource`\n\n4) 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`.\n\n5) Choose `Actions -\u003e Deploy API`, set `Deployment stage` as `[New Stage]`, enter stage name and click `Deploy`\n\n6) Now you should be able to invoke the lambda renderer by navigating to `https://your-invoke-url/your-stage-name/index`\n\n## Setting up CloudFront\n\n1) 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`.\n\n2) Set your custom domain in `Alternate Domain Names\n(CNAMEs)`\n\n3) You can leave other settings as they are if you don't want to customize anything, click `Create distribution`.\n\n4) Go to your distribution, navigate to `Origins`, click `Create origin`\n\n5) Choose your S3 bucket (you should create it now if you haven't already. Make sure there's `assets` directory). Click `Create`.\n\n6) Go to your distribution, navigate to `Behaviors`, click `Create Behavior`.\n\n7) Set `Path Pattern` as `assets/*`, choose your S3 origin and click `Create`.\n\n8) In your domain's DNS management interface, point your domain's `CNAME` to your CloudFront distribution.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoppula%2Freact-apig-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoppula%2Freact-apig-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoppula%2Freact-apig-lambda/lists"}