Question · Next.js course · Module 1: Next.js Configuration

Client-Side Environment Variables in Next.js

How do you define environment variables accessible on the client side in Next.js?

Answer options

  • By placing the variable in a client.env file
  • By adding the NEXT_PUBLIC_ prefix to the variable name
  • By exporting the variable from next.config.js
  • By adding the CLIENT_ prefix to the variable name
Show the answer

Correct answer:

  • By adding the NEXT_PUBLIC_ prefix to the variable name