- LIVE
There is alot of issues with various webpacks and proxy issues in regards to react + build commands....this right now will work locally or on deployment to netlify, it also has some files already modified for you such as redirects so you can use react-router etc with ease.
Deploy to netlify or run locally.... simply change any notice of yarn to npm during netlify deployment set up.
Added POST demo
Added Node boiler plate
npm i -g netlify-cli
clone repo
npm i
npm run dev
All functions (inside src/lambda
) are compiled with webpack using Babel, so you can use modern JavaScript, import npm modules, etc., without any extra setup.
## prep steps for first time users
npm i -g netlify-cli # Make sure you have the [Netlify CLI](https://github.com/netlify/cli) installed
git clone https://github.com/Kirbyasdf/netlfiy-lambda-boilerplate.git ## clone this repo
cd create-react-app-lambda ## change into this repo
npm i # install all dependencies
## done every time you start up this project
ntl dev ## nice shortcut for `netlify dev`, starts up create-react-app AND a local Node.js server for your Netlify functions
This fires up Netlify Dev, which:
- Detects that you are running a
create-react-app
project and runs the npm script that containsreact-scripts start
, which in this project is thestart
script - Detects that you use
netlify-lambda
as a function builder, and runs the npm script that containsnetlify-lambda build
, which in this project is thebuild:lambda
script.
You can view the project locally via Netlify Dev, via localhost:8888
.
Each function will be available at the same port as well:
http://localhost:8888/.netlify/functions/hello
andhttp://localhost:8888/.netlify/functions/async-dadjoke
During deployment, this project is configured, inside netlify.toml
to run the build command
: npm build
.
npm build
corresponds to the npm script build
, which uses npm-run-all
(aka run-p
) to concurrently run "build:app"
(aka react-scripts build
) and build:lambda
(aka netlify-lambda build src/lambda
).
For a full demo of routing and authentication, check this branch: netlify/create-react-app-lambda#18 This example will not be maintained but may be helpful.