Doppler and Next.js without Vercel

We run next.js outside of vercel and I’m struggling to get the env variables to be passed through to next dev or next build

I’ve tried within package.json:
doppler run -- next dev
doppler run --mount .env run -- next dev

I’ve also tried both when calling it through yarn: doppler run -- yarn dev

Can anyone help point me in the right direction?

Hi @Matt_Matey,

Welcome to the Doppler Community!

What you’re doing should work fine! I just created a fresh example nextjs project following the instructions here. I modified the page.tsx file in that project to print out process.env.MY_SECRET_NAME and that value printed as expected. It also picked up the PORT secret I was passing in and bound to the appropriate port.

Depending upon what you’re trying to do, this section of Next.js’s docs might be relevant to you:

If none of that helps, could you elaborate a bit more with specifically how you’re determining the secrets aren’t passing through? If you set a PORT variable, does the server start on the passed in port rather than the default 3000 port?

Regards,
-Joel

It’s an empty object for process.env. I’m console logging it… and the API endpoint are trying to set is coming back as undefined.

I’ll take a look at it some more and test it some more.

We have both NEXT_PUBLIC_ and normal env names and neither are showing which is frustrating

@Matt_Matey If you change the command in package.json to doppler run -- printenv and then inspect the environment – are the Doppler secrets you expect showing up there? Also, can you confirm that the DOPPLER_ secrets are showing the expected project and config?