# Doppler and Next.js without Vercel

**URL:** <https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535>\
**Category:** Need Help\
**Created:** [May 22, 2024, 1:57pm UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535 "2024-05-22T13:57:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Matey](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/matt_matey/32/1062_2.png) [@Matt\_Matey](https://community.doppler.com/u/Matt_Matey)\
**Post date:** [May 22, 2024, 1:57pm UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535/1 "2024-05-22T13:57:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![watsonian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/watsonian/32/267_2.png) [@watsonian](https://community.doppler.com/u/watsonian)\
**Post date:** [May 22, 2024, 6:00pm UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535/2 "2024-05-22T18:00:06Z")

</div>

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](https://nextjs.org/learn/dashboard-app/getting-started). 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:

> **[Configuring: Environment Variables | Next.js](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser)**
>
> Learn to add and access environment variables in your Next.js application.

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

---

<div class="post-metadata">

**Author:** ![Matt\_Matey](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/matt_matey/32/1062_2.png) [@Matt\_Matey](https://community.doppler.com/u/Matt_Matey)\
**Post date:** [May 24, 2024, 2:10pm UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535/3 "2024-05-24T14:10:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![watsonian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/watsonian/32/267_2.png) [@watsonian](https://community.doppler.com/u/watsonian)\
**Post date:** [May 24, 2024, 8:06pm UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535/4 "2024-05-24T20:06:33Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![rnbrady](https://sea2.discourse-cdn.com/flex016/user_avatar/community.doppler.com/rnbrady/32/1288_2.png) [@rnbrady](https://community.doppler.com/u/rnbrady)\
**Post date:** [July 25, 2025, 8:40am UTC](https://community.doppler.com/t/doppler-and-next-js-without-vercel/1535/5 "2025-07-25T08:40:58Z")

</div>

`console.log(process.env)` will always return an empty object client side because environment variables are “inlined into the JavaScript bundle during `next build`” to quote the [docs](https://nextjs.org/docs/app/guides/environment-variables#runtime-environment-variables). Same happens for `next dev`.

You should never get an empty object server side because even with no .env file you will still see variables like NODE\_ENV.
