Setting up a `ReactStaticSite` but getting an erro...
# sst
c
Setting up a
ReactStaticSite
but getting an error trying to pass env variables to the react app.
Copy code
sst-env: Cannot find the SST outputs file in /Users/colin/dev/api. Make sure "sst start" is running.
This happens when trying to start up the react dev server with the command
sst-env -- react-scripts start
. Occurs while I have
sst start
running.
f
What’s the folder structure of ur repo? (ie. path to sst.json and to your react app)
c
Copy code
lib/
src/
    docs/ # react app here
test/
sst.json
f
Can I see what’s in ur
.build
?
c
yep - of react directory or root?
f
root
d
Any update on this? I seem to be having this same issue!
f
Hey @Dillon Peterson, what’s the folder structure of ur entire repo (ie. path to the SST app, and path to the React app)?
d
And it's a static NextJS site -- in next-client folder of top-level, which is first screenshot.
Also @Frank, I don't really have a need for SSR atm, I just picked up NextJS recently because it looked cool. Would you recommend using React over NextJS for SST projects, or does it not really matter?
f
Yeah that doesn’t matter. Can I see how you are defining the site in ur SST code?
hmm that looks right! Also when you ran into the error, was
sst start
running?
c
fwiw @Dillon Peterson this usually gets resolved for me when i make sure both
@serverless-stack/cli"
and
@serverless-stack/resources
are the same version and I wait until
sst start
has fully spun up before starting up the static site.
d
@Frank Yes Sir SST start was running. @colin Thank you, I will try that!
f
@Dillon Peterson Let me know how it goes.
d
That seems to have worked. Also had an issue where env variables weren't being forwarded to client. All working good now. Thanks @Frank and @colin!
f
Nice! Do you recall what you did to get it to work?
t
I'm also experiencing this and would like to know what @Dillon Peterson did to get it working.
f
Hey @Tim, did you check this suggested by @colin? https://serverless-stack.slack.com/archives/C01HQQVC8TH/p1629227034263000
d
Hi @Frank and @Tim, I did what @colin suggested and it worked. My versions were the same, but I wasn’t waiting on SST Start to finish booting up before firing up the client.
And I also used a different build command to start up the NextJS app. Instead of “next start”, I run “next”. So full package.json is this…
I use yarn as package manager and run yarn dev.
@colin, also you’ll have to specify which ENV variables to pass through to client — since by default NextJS holds ENV variables for backend API routes (NextJS, not SST) only unless specified otherwise.
Here’s my next.config.js