Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: No info on environment variables in the /src folder #33110

Closed
atenie opened this issue Jan 9, 2022 · 2 comments
Closed

Docs: No info on environment variables in the /src folder #33110

atenie opened this issue Jan 9, 2022 · 2 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@atenie
Copy link
Contributor

atenie commented Jan 9, 2022

What is the improvement or update you wish to see?

Change this line in this page:

Config files like next.config.js and tsconfig.json should be inside the root directory, moving them to src won't work. Same goes for the public directory

To:

Config files like next.config.js and tsconfig.json, as well as environment variables, should be inside the root directory, moving them to src won't work. Same goes for the public directory

And add a note here:

Note: If you are using a /src folder, please note that Next.JS will load the .env files only from the parent folder and not from the /src folder.

Is there any context that might help us understand?

I've had this tiny issue that I didn't think of, but maybe one line in the documentation might help other people as well, since it's a small thing that is not mentioned: if you, by any chance, have environment variables in your /src folder, they're not gonna be read by the program. If you have them in the parent folder however, they will be read. Maybe it's not the most important problem around, but it would be great if it would be mentioned in the documentation somewhere (if not on both the Environment Variables page as well as the /src folder one).

Kind regards

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables
https://nextjs.org/docs/advanced-features/src-directory

@atenie atenie added the Documentation Related to Next.js' official documentation. label Jan 9, 2022
@balazsorban44 balazsorban44 added area: documentation and removed Documentation Related to Next.js' official documentation. labels Jan 9, 2022
@balazsorban44
Copy link
Member

If you want to open a PR, here are the relevant files:

https://github.com/vercel/next.js/blob/canary/docs/basic-features/environment-variables.md
https://github.com/vercel/next.js/blob/canary/docs/advanced-features/src-directory.md

@balazsorban44 balazsorban44 added the good first issue Easy to fix issues, good for newcomers label Jan 10, 2022
Amila-Rukshan added a commit to Amila-Rukshan/next.js that referenced this issue Jan 10, 2022
Docs: No info on environment variables in the /src folder vercel#33110
link to the docs => https://nextjs.org/docs/advanced-features/src-directory
kodiakhq bot pushed a commit that referenced this issue Jan 10, 2022
Proposes fix to #33110

Adds info on environment variables and the /src folder in the following docs:

- https://nextjs.org/docs/advanced-features/src-directory
- https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
teleaziz added a commit to teleaziz/next.js that referenced this issue Jan 11, 2022
…into cms-builder-io-example

* 'cms-builder-io-example' of github.com:teleaziz/next.js: (22 commits)
  drop dynamic import with `ssr: false` on server-side (vercel#32606)
  next-swc: fix ssg code elimination when used in render (vercel#32709)
  Add Caveats section to custom error page (vercel#33160)
  v12.0.8-canary.20
  Allow dependencies to use environment variables in middlewares (vercel#33141)
  use a separate webpack runtime for middleware (vercel#33134)
  No info on environment variables in the src folder (vercel#33110) (vercel#33136)
  docs: minor text-copy cleanup (vercel#33120)
  Update swc (vercel#33063)
  Update next.config.js (vercel#33091)
  Adding Asset Component for Rich Text Renderer (vercel#32503)
  Update using-mdx.md (vercel#33077)
  v12.0.8-canary.19
  Fix middleware at root in standalone mode (vercel#33053)
  Add util for generating new tests/error documents (vercel#33001)
  Remove extra config from tailwind example (vercel#33062)
  Fix link for Next.js Analytics in docs (vercel#33049)
  Bump `@vercel/nft` to 0.17.2 (vercel#33048)
  Update deployment documentation. (vercel#32006)
  v12.0.8-canary.18
  ...
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants