SimoAmi
Context parameters in server side calls
Hello, I using trpc 11.0.0-rc.633 and Next.js 15.0.3 and have the following questions:
1. when a
and then runs it without passing any parameters: 2. My context needs access to the requesting url query string to get a token (used for shared links). How do I get the url or query parameters in a server call where I don't have implicit access to the request object?
3. In the Next.js main layout, where a
createContext()
function is defined with the FetchCreateContextFnOptions
parameter signature, how do you fill that information out when using server side api calls, for example via createCaller
? The example in the docs is inaccurate in that it defines a createContext
function to require some parameters:
and then runs it without passing any parameters: 2. My context needs access to the requesting url query string to get a token (used for shared links). How do I get the url or query parameters in a server call where I don't have implicit access to the request object?
3. In the Next.js main layout, where a
<RootLayout />
is defined, I need to fetch the current user to pass it along to react components. I have a getUser()
procedure for this. Do I use the client side api defined with createTRPCReact
to call the procedure? or can I use the server side api created with a createCaller
since I assume the root layout will be rendered on the server side?2 replies