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;

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
Was this page helpful?