Next.js Discord

Discord Forum

T3 env with next.config.ts in v15.0.0-canary.179

Unanswered
American Fuzzy Lop posted this in #help-forum
Open in Discord
American Fuzzy LopOP
Hi

I'm trying to use T3 env https://env.t3.gg/docs/nextjs in my config.next.ts but it gives me error I also try to use it without "jiti" but it does not work and server do not start

I use bun in my project

my next config code
===================
import type { NextConfig } from "next";
import { env } from "@/env/server";

const nextConfig: NextConfig = {
  experimental: {
    typedRoutes: true,
  },
  env: {
    ...env,
  },
};

export default nextConfig;


and my src/env/server.ts code
===========================
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
  server: {
    NODE_ENV: z.enum(["development", "production"]),
  },
  emptyStringAsUndefined: true,
  experimental__runtimeEnv: process.env,
});

13 Replies

American Fuzzy LopOP
Is there a way to use this with next.config.ts?
@American Fuzzy Lop Is there a way to use this with next.config.ts?
afaik, no because next.config.ts is still too new so the lib hasn't been updated to support that currently.
@joulev [#63051](<https://github.com/vercel/next.js/pull/63051>), v15.0.0-canary.60
Oh damn it was a while ago, probably why I missed it. Joined the canary train in late august.
Yeah I just switched to using next.config.ts and no issues for me either.
American Fuzzy LopOP
actually i enable the organizeImports on my .vscode/setting.json file which automatically delete my ENV import in next-config.ts because it's not used so there is any way to disable this setting on a specific file ?
    "editor.codeActionsOnSave": {
        "source.organizeImports": "always"
    },