T
tRPC

❓-help

trpc output dates are typed as strings and not dates

TTaylorFay1/12/2024
I'm using superjson as a transformer. When I query my data, it shows that fields that should be dates are typed as strings. How can I get them to be typed as dates?
Nnlucas1/12/2024
Have you set it up on both the server and the client?
TTaylorFay1/12/2024
Yes. client
const [trpcClient] = React.useState(() =>
trpc.createClient({
transformer: superjson,
links: [
httpLink({
url: absoluteUrl('/api/trpc')
})
]
})
);
const [trpcClient] = React.useState(() =>
trpc.createClient({
transformer: superjson,
links: [
httpLink({
url: absoluteUrl('/api/trpc')
})
]
})
);
server
const t = initTRPC.context<typeof createContext>().create({
transformer: superjson
});
const t = initTRPC.context<typeof createContext>().create({
transformer: superjson
});
If it helps, I have a Next13 app using the app router. I don't believe @trpc/next works on the app router, so I'm using '@trpc/react-query'
Nnlucas1/12/2024
Well that should be enough, though not sure if there are any weirdnesses in AppRouter or NextJS as I'm not a big user of those Make sure you've restarted your language server
DDINO2/16/2024
I have the same problem using electron-trpc
SSwaroop2/17/2024
I tried superjson transformer recently with the App router Next.js. It worked for me. Giving a reproducible repo will help much to solve this issue.
DDINO2/19/2024
Yes I have solved it with superjson

Looking for more? Join the community!

Recommended Posts
TRPC v10 to v11 - change logs locationWhere can I read the changlogs from v10 to v11? I have seen the migration guide, but no clear list tRPC won't return route with function, only JSONHey all, Why can I go to route 'test' and the 'This is a test!' is being returned, but when I try ttRPC router won't return, unless it's just json.Hey all, Why can I go to 'test' and the 'This is a test!' is being returned, but when I try to go tHow to make trpc output return strings and not datesI am **not** using superjson I would like for all of my trpc routes to return dates as strings. HowCannot read properties of undefined (reading 'input')login: trpc_1.publicProcedure.input(loginInput).mutation((opts) => __awaiter(void 0, void 0, void 0,Extending the client with "virtual" proceduresI'm hoping to write a virtual mutation which runs on the client and calls some other client-side apiDynamic Server Usage Error from RSC callsposted this on the create-t3-app server as well but not quite sure if the issue is T3 or TRPC relateNode 20, NPM: Send form values to DB with tRPC?Hey all, anyone in here with some tRPC experience? I have been going through YouTube video's and thGetting type error in v11 when trying to instantiate createTRPCQueryUtils```Type 'CreateTRPCReactBase<CreateRouterInner<RootConfig<{ ctx: object; meta: object; errorShape: DLoggerLink logging only via server logger in prodI have a logger link setup as declared in https://trpc.io/docs/client/links/loggerLink#usage ```ts Better error tracing when using TRPC routersHi, I'm using a trpc router and noticed that the error trace report is more or less non existent as client side Validation with ZODwill trpc validate input on the client before sending it to the server ?We're having some serious Intellisense performance issues with v10Hello. We have about ~30ish routers in `mergeRouters` (we're working on changing this to a namespaceParsing FormData on trpcHi all, I have function to put object on S3 const putObjectToS3 = async (body: FormData) => { ... }TRPC to connect a client app with a backend apigateway ?Hi everyone! Is it a good practice to use TRPC to connect my client application (Next.Js) with my bWebsocket server implementations with TRPC createWSClientIs anyone aware of a websocket server that is compatible with trpc websocket client that isn't usingAdvanced Permissioning In MiddlewareI need to handle somewhat complicated permissioning logic, for example: `User A can read (but not How is the Client Generated with just the typesI'm trying to build a trpc like app for building restful apis with sveltekit. In trpc sveltekit only