Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’16mo agoβ€’
3 replies
shandy

Using drizzle postgres with trpc in Next.js app

I'm getting the following error with the below code:
Module not found: Can't resolve 'dns'
Module not found: Can't resolve 'dns'
. For some reason, my Next.js app is trying to load
drizzle
drizzle
on the client where it doesn't have access to Node modules. Has anyone ever run into this before?


import { publicProcedure, router } from "../trpc";
import { z } from "zod";

import { drizzle } from "drizzle-orm/node-postgres";

// If I comment out this function, the error goes away.
export const createDbClient = () => {
  return drizzle(process.env.DB_URL!);
};

const formSchema = z.object({
  name: z.string().min(1, "Must provide a name."),
  email: z.string().email(),
});

export const formRouter = router({
  test: publicProcedure.query(() => {
    return `test`;
  }),
  submit: publicProcedure.input(formSchema).mutation(({ input }) => {
    // const client = createDbClient();

    return `received form values`;
  }),
});

export type FormRouter = typeof formRouter;
import { publicProcedure, router } from "../trpc";
import { z } from "zod";

import { drizzle } from "drizzle-orm/node-postgres";

// If I comment out this function, the error goes away.
export const createDbClient = () => {
  return drizzle(process.env.DB_URL!);
};

const formSchema = z.object({
  name: z.string().min(1, "Must provide a name."),
  email: z.string().email(),
});

export const formRouter = router({
  test: publicProcedure.query(() => {
    return `test`;
  }),
  submit: publicProcedure.input(formSchema).mutation(({ input }) => {
    // const client = createDbClient();

    return `received form values`;
  }),
});

export type FormRouter = typeof formRouter;
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Setting up Drizzle with Supabase in Next.js App Router
Drizzle TeamDTDrizzle Team / help
3y ago
Cant drizzle-kit pull with next.js from supabase postgres
Drizzle TeamDTDrizzle Team / help
17mo ago
DRIZZLE + NEXTJS App router + Supabase Error postgres js timeout
Drizzle TeamDTDrizzle Team / help
2y ago
DRIZZLE + NEXTJS App router + Supabase Error postgres js timeout
Drizzle TeamDTDrizzle Team / help
2y ago