tRPCttRPC
Powered by
gdagleyG
tRPC•3y ago•
1 reply
gdagley

Understanding how too reuse TRPC with React Server Components

Hopefully I am understanding this correctly, but I have created a
experimental_createTRPCNextAppDirServer
experimental_createTRPCNextAppDirServer
server to reuse my router with Next.js Server Components.

export const api = createTRPCNextAppDirServer<typeof appRouter>({ ... })
export const api = createTRPCNextAppDirServer<typeof appRouter>({ ... })


In my React server component, when I do
const workspace = await api.workspaces.getWorkspaceById.query({ id: params.workspaceId })
const workspace = await api.workspaces.getWorkspaceById.query({ id: params.workspaceId })
do I need to wrap it in
try/catch
try/catch
block to handle the possible TRPCErrors that my router would throw if it was called from the client?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Using react server components with separate API
ArxkAArxk / ❓-help
3mo ago
tRPC sockets with react
rocawearRrocawear / ❓-help
4y ago