how to pass zod object from server component to client components as props
Answered
Giant panda posted this in #help-forum
Giant pandaOP
how to pass zod object from server component to client components as props
Answered by Alfonsus Ardani
zod arent serializable; this means not only that it wouldn't work passing server to client, but storing it to a database. I think its better you change to a library that supports serializable schema like [superstruct](https://docs.superstructjs.org/)
10 Replies
@Giant panda how to pass zod object from server component to client components as props
why do you want to do that? zod schemas are static so can be imported to the client components directly
@joulev why do you want to do that? zod schemas are static so can be imported to the client components directly
Giant pandaOP
to create some basic fields based on schema
@Giant panda to create some basic fields based on schema
you meant to create dynamic schema based on user input?
Giant pandaOP
yes
want to store schema in db and fetch and give to a client component
why do you need to store the schema in the db again?
Giant pandaOP
to create some basic fields based on schema,
schema that can be changed by the users -> so want to, also store it in db
schema that can be changed by the users -> so want to, also store it in db
@Giant panda to create some basic fields based on schema,
schema that can be changed by the users -> so want to, also store it in db
zod arent serializable; this means not only that it wouldn't work passing server to client, but storing it to a database. I think its better you change to a library that supports serializable schema like [superstruct](https://docs.superstructjs.org/)
Answer
or you know, you can make your own schema parser, you know, keep the scope small