/static-react-example

Primary LanguageJavaScriptMIT LicenseMIT

React with Layer0

This example is built with React to demonstrate the use and configuration of Layer0 serving a client-side-rendered application. We utilize the caching and speed optimizations provided by Layer0 to serve static resources that are rendered on the client.

Demo

https://layer0-docs-layer0-static-react-example-default.layer0.link

Try It Now

Deploy with Layer0

Getting Started

Clone This Repo

Use git clone https://github.com/layer0-docs/static-react-example.git to get the files within this repository onto your local machine.

Install dependencies

On the command line, in the project root directory, run the following command:

npm install

Run the React app locally on Layer0

Run the React app with the command:

npm run layer0:dev

Load the site: http://127.0.0.1:3000

Testing production build locally with Layer0

You can do a production build of your app and test it locally using:

layer0 build && layer0 run --production

Setting --production runs your app exactly as it will be uploaded to the Layer0 cloud using serverless-offline.

Deploying to Layer0

Deploying requires an account on Layer0. Sign up here for free. Once you have an account, you can deploy to Layer0 by running the following in the root folder of your project:

layer0 deploy

See deploying for more information.