Created
July 29, 2023 01:45
-
-
Save KrisKnez/d945188f4e6603246456f5ba8064c22d to your computer and use it in GitHub Desktop.
Next.JS env with envalid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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