A simple CLI (
@serverless-stack/static-site-env that allows your static site to load the environment variables from your SST app. This means that you won't have to hard code the config from your backend.
Read more about how this works over on the
Run the following in the root of your static site.
Once installed, tweak the start command in your
Now start your static site as usual.
Note that, you need to have
sst start running for this to work.
Here's what's going on behind the scenes.
sst startcommand generates a file with the values specified by
sst-envCLI will traverse up the directories to look for the root of your SST app.
- It'll then find the file that's generated in step 1.
- It'll load these as environment variables before running the start command.
sst-env only works if the React app is located inside the SST app or inside one of its subdirectories.