-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
how to validate schema on build on next.config.ts #281
Comments
Yeah, I'm interested in this too. I'm trying something like the following, but it doesn't seem to work. import { env as clientEnv } from "@/lib/env/client";
import { env as serverEnv } from "@/lib/env/server";
// ... |
I already submitted a PR for this, so basically, it is as simple as just importing the env file in import type { NextConfig } from "next";
// Import env here to validate during build.
import "./app/env";
const nextConfig: NextConfig = {
/** ... */
}; |
@chungweileong94 I am already importing it into my next.config.ts file and it doesn’t work for me. See my previous comment. I am using Next.js 15 canary with the turbo flag. |
Can you provide a small repo for it? |
@jferrettiboke I renamed next.config.js to next.config.ts and env.js to env.ts. (the latter is not necessary here, I think) In next.config.ts: Of course you use own path like ./app or else. |
Thanks @chungweileong94 @phl23! I was importing in another way. It now works for me. Before: import type { NextConfig } from "next";
import { env as clientEnv } from "@/lib/env/client";
import { env as serverEnv } from "@/lib/env/server";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig; After: import type { NextConfig } from "next";
import "@/lib/env/client";
import "@/lib/env/server";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig; |
Next.js config now support
.ts
, and in this documentation https://env.t3.gg/docs/nextjs#validate-schema-on-build-(recommended) need jiti to load.ts
onnext.config.mjs
.does this need to be updated? and how to do it correctly and cleanly?
The text was updated successfully, but these errors were encountered: