© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
c0ldh4ck

Help with Drizzle-zod

Hi all,

Working with SvelteKit I have a types/index.ts file in my lib folder. I want to create Schema and Types for zod validations for forms this way:

import { createInsertSchema, createSelectSchema } from 'drizzle-zod';
import { locations } from '$lib/server/database/schema';

export const insertLocationSchema = createInsertSchema(locations);
export const selectLocationSchema = createSelectSchema(locations);
export type insertLocationType = typeof insertLocationSchema;
export type selectLocationType = typeof selectLocationSchema;
import { createInsertSchema, createSelectSchema } from 'drizzle-zod';
import { locations } from '$lib/server/database/schema';

export const insertLocationSchema = createInsertSchema(locations);
export const selectLocationSchema = createSelectSchema(locations);
export type insertLocationType = typeof insertLocationSchema;
export type selectLocationType = typeof selectLocationSchema;


I am getting an error that I cannot import server side code into client side components, which I understand. But I have my schema and all other DB relatated setup in $lib/server folder.

How would I manage to use these types in for example a 'Create Location Form' component?

I am using sveltekit-superforms and returning that via a +page.server.ts, I am a bit confused. Hopefully someone has some experience with SvelteKit and this
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

Help, Partial select with drizzle-zod
Drizzle TeamDTDrizzle Team / help
2y ago
help with drizzle-zod with jsonb column
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle-zod combined with regular zod? 🙃
Drizzle TeamDTDrizzle Team / help
15mo ago
Drizzle Zod with relations
Drizzle TeamDTDrizzle Team / help
2y ago