T
tRPC

❓-help

Page couldn't be rendered statically because it used `cookies`

PMPablo M12/3/2023
Has anyone had this issue? I'm using trpc in a server component and in localhost it works fine but it won't work when deployed toVercel. Any help will be appreciated
No description
No description
PMPablo M12/3/2023
solved adding force-dynamic, not sure if it's the best solution
Nnirjhor12/4/2023
Well you haven't solved it, force dynamic forces it to not be static But yes, you cannot access cookies on static pages
LLittleLily12/4/2023
It seems like the most likely cause for getting the error is the failure of the nextjs auto-detection of dynamic routes based on use of cookies/etc due to it not being able to follow the chain of calls that results in cookies being used. It's happened to me a few times where I had a page that used cookies, then I moved the cookie usage to an external file that the page imported instead, and that must break the auto-detection and so nextjs thinks the page can be statically rendered even though it can't in reality. If that's the situation you're in then setting force-dynamic is the correct solution since it likely already needed to be dynamic, it just wasn't able to be detected. Even though the detection of dynamic routes/pages is mentioned in the docs somewhere, I think it would be better if it was made a little more obvious and upfront in the docs that the detection of dynamic vs static routes isn't always going to work, and I think it should recommend that you should probably just explicitly set force dynamic on routes that you know will use cookies, because otherwise the build will just decide to fail randomly one day when you refactor code that is functionally identical but stumps the detection in nextjs
PMPablo M12/4/2023
but i just need ssr, i guess it solves the needs? yeah makes sense I think it's more a vercel/next thing

Looking for more? Join the community!

T
tRPC

❓-help

Join Server
Recommended Posts
Comparing tRPC and Server Actions for a SaaS Template: Seeking Insights and AdviceHey everyone 👋, I've just posted a detailed comparison and discussion request on Reddit about tRPCsetting up trpc in next 14Pleaase I need help on how to integrate trpc in next js 14, please help mecreateTRPCReact transformers getting type errorHave anyone tried migration from TRPC router to app router apiI was learning the trpc and I wanna know to go back and forth with trpc and restapi. can anyone knowHas anyone integrated trpc + udp (quic/webtransport api)?Hi all, I'm thinking about taking advantage of quic for a certain part of my project. Basically I'm onSuccess invalidateI'm trying to follow along with Theo's T3 tutorial using the latest Next version and the app routerReact Query client and caller client under one objectWould love to know if it is possible to have caller and react query clients under one object? I feeI want to refetch and set the inital data of an useStateHello guys, currently i am retrieving the data i use in useState with `SSR`, but i want to use someVanilla Client Error HandlingWhat is the right way to handle errors when using the vanilla client? If I setup a client like so: sidebar searchPlease how will I implement a search on the left sidebar to let the items on the search bar be searcWS with TRPC```ts │ îȘ‡ Type '({ req, res, }: { req: Request; res: Response; }) => CreateInnerContextOpts' is tRPC is butchering object types in return typesSo if I have a mutation that returns this type ```ts { name?: string } ``` the type that tRPC infersWhy my Authorization does not update ?i have this in `_app.tsx` ```export default function App({ Component, pageProps }: AppProps) { retTypeError: queryClient.getMutationDefaults is not a function (it is undefined)Hi! There's not much code to show here, as I'm really not sure where the error actually occurs. InuseQuery never returning or hitting APII have something off in my configuration, i copied most of the files from the `❯ npm create t3-app@lType 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutationI am trying to setup a new project and doing my first client side query and getting this error: ```trpc mutation call stuckI have an issue with a simple mutation procedure: `getPublicUser: publicProcedure .input(z.objeCreate client based on OpenAPIHi! I am running a golang server with an openapi spec and would love to use trpc client in my fronte