Skip to content

Instantly share code, notes, and snippets.

@KrisKnez
Created July 29, 2023 01:45
Show Gist options
  • Save KrisKnez/d945188f4e6603246456f5ba8064c22d to your computer and use it in GitHub Desktop.
Save KrisKnez/d945188f4e6603246456f5ba8064c22d to your computer and use it in GitHub Desktop.
Next.JS env with envalid
import { cleanEnv, url } from "envalid";
// We have to do this because of how Next.JS handles process.env
const processEnv = {
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
};
const env = cleanEnv(processEnv, {
NEXT_PUBLIC_API_URL: url(),
});
export default env;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment