How to handle Primsa DateType (JS Date) in getStaticProps | getServersideProps

I keep running into serialization issues when working with schemas that include a DateType since they are transformed into JS Date which is not JSON serializable. Atm I am transforming the Dates into numbers (miliseconds) to then pass to the component. But of course typescript is complaining. I wrote a generic that replaces Date types with number types inside another type but so far this does not work for nested types. There has to be a better way. Pls help.
3 Replies
Neto
Neto2y ago
npm
superjson
. Latest version: 1.11.0, last published: 23 days ago. Start using superjson in your project by running npm i superjson. There are 61 other projects in the npm registry using superjson.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
andersgee
andersgee2y ago
You can use next-superjson which solves exactly this https://github.com/remorses/next-superjson
GitHub
GitHub - remorses/next-superjson: Automatically transform your Next...
Automatically transform your Next.js Pages to use SuperJSON, without losing swc support - GitHub - remorses/next-superjson: Automatically transform your Next.js Pages to use SuperJSON, without losi...
Want results from more Discord servers?
Add your server