Yarn # install all dependencies # done every time you start up this project Git clone # clone this repo cd create-react-app-lambda # change into this repo Npm i -g netlify-cli # Make sure you have the () installed Learn how to set this up yourself (and why everything is the way it is) from scratch in a video: Babel/webpack compilationĪll functions (inside src/lambda) are compiled with webpack using Babel, so you can use modern JavaScript, import npm modules, etc., without any extra setup. We've also included an async lambda example using async/await syntax in async-dadjoke.js. ![]() This folder is specified and can be changed in the package.json script: "build:lambda": "netlify-lambda build src/lambda".ĭist: Each JavaScript file in there will be built for Netlify Function deployment in /built-lambda, specified in netlify.toml.Īs an example, we've included a small src/lambda/hello.js function, which will be deployed to /.netlify/functions/hello. Source: The main addition to base Create-React-App is a new folder: src/lambda. Netlify Dev works with create-react-app out of the box! Only use netlify-lambda if you need a build step for your functions, eg if you want to use Babel or TypeScript ( see its README for details). ⚠️NOTE: You may not need this project at all. Alternatively you can deploy straight to Netlify with this one-click Deploy: You can clone this and immediately be productive with a React app with serverless Netlify Functions in the same repo. ![]() This project is a reference demo showing you how to use Create React App v3 and netlify-lambda v1 together in a Netlify Dev workflow.
0 Comments
Leave a Reply. |