Skip to content
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

docs: update guide for schema validation on build for Next.js 15 #282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chungweileong94
Copy link
Contributor

Since now that Next.js 15 supports TypeScript for next.config.ts, we no longer need jiti for importing schema TS file. We will update the guide for Next.js 15, while still keeping the old guide for Next.js 14 or below.

fix #281

Copy link

vercel bot commented Nov 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
t3-env ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2024 2:56pm

Copy link

vercel bot commented Nov 3, 2024

@chungweileong94 is attempting to deploy a commit to the t3-oss Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines +110 to +125
We recommend you importing your newly created file in your `next.config.ts`. This will make sure your environment variables are validated at build time which will save you a lot of time and headaches down the road.

```ts title="next.config.ts"
import type { NextConfig } from "next";

// Import env here to validate during build.
import "./app/env";

const nextConfig: NextConfig = {
/** ... */
};
```

<Callout type="info">

If you’re using Next.js version 14 or below, you can use [unjs/jiti](https://github.com/unjs/jiti) to import TypeScript files in your `next.config.js`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we should have this it should alos come with a warning about the shortcomings of using esm in next.config.ts. for example import.meta.dirname etc is undefined. i recommend sticking to js config until they fix this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliusmarminge is this also the case when using "type": "module" in the package.json file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - it's how they transpile the next.config.ts that's the problem, they call it out in their docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to validate schema on build on next.config.ts
3 participants