-
Notifications
You must be signed in to change notification settings - Fork 23
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
Use @next/env instead of dotenv in Next.js App Examples #300
Comments
Thank you for the suggestion. I do not think it is necessary. Our purpose with these examples is to show how to utilize the New Relic Node.js agent with Next.js, not to provide tutorials for Next.js itself. Personally, I am also 100% against adding any sort of |
Yes, I agree with not using const { loadEnvConfig } = require('@next/env')
const projectDir = process.cwd()
loadEnvConfig(projectDir) Then you don't need to add I added because the second argument of I asked because there are some of posts and issues asking about this on other threats, like these: But none of them seems to work correctly with the same env files configuration NextJS suggest to use, we need to use |
The |
@josbelluna this example is just demonstrating the observability the New Relic Node.js agent provides as well as some examples of common problems our customers hit: injecting browser agent, forwarding logs, handling errors. This is not intended to be a template for the best way to use the Node.js agent with Next.js. |
Is your feature request related to a problem? Please describe.
No
Feature Description
For NextJS App Examples, use
@next/env
instead ofdotnev
to match NextJS environment variables.There are some issues using
dotnev
library directly to load NextJSenv
variables, for example trying to load them from.env.local
doesn't work by default.NextJS now exposes
@next/env
package that can be used to get the same results as the main process:https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#loading-environment-variables-with-nextenv
The text was updated successfully, but these errors were encountered: