tRPCttRPC
Powered by
OctaviusO
tRPC•17mo ago•
1 reply
Octavius

withTRPC not working in RootLayout

I followed the T3 example to set up TRCP in my project https://create.t3.gg/en/examples. I am using the newer next file strucuture with the app folder, no pages folder, no _app file, but a root app/layout.tsx file. I want to use withTRCP on the export of the root layout. However I get the error:
Error: useState only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/react-client-hook-in-server-component
Error: useState only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/react-client-hook-in-server-component
. Do I have to scrap the layout file and put everyting into _app or is there a cleaner solution?
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

`QueryClientProvider` not included in `withTRPC`?
Jack FischerJJack Fischer / ❓-help
4y ago
Next.js/tRPC RootLayout Caching Error
oimmiOoimmi / ❓-help
3mo ago
TRPCProxyClient not working in createTRPCNext
Answer OverflowAAnswer Overflow / ❓-help
3y ago