You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I'm running into an error with TanStack Start - Internal server error: createServerFn must be assigned to a variable!
My basic use case is trying to convert from a tRPC project, in which I really enjoy to DX of defining all of my APIs and then it's as simple as calling trpc..useQuery(param) in a component and you can rock from there
I understand how to create serverFns in Start and use them in components, and have also plugged in TanStack Router to handle some of this in components. My issue is that it can become a little verbose in using these serverFns in client components, like this: (just for example, specifics don't matter too much here)
I'm trying to re-create tRPC-like functionality in TanStack Start, and have some code below to start it - but then I run in to the error in the title: "Internal server error: createServerFn must be assigned to a variable!"
The text was updated successfully, but these errors were encountered:
tomkennedy22
changed the title
[Start] - Internal server error: createServerFn must be assigned to a variable!
[Start] - Internal server error: createServerFn must be assigned to a variable
Jan 20, 2025
Also tried a workaround where I define the functions in a loop then assign to a object, but ran into similar error in Server Functions cannot be nested in other blocks or functions
And from what I can tell, it requires the function to be set to a variable so the variable name can later be used for internal routing to the right function. Which makes sense, but ultimately blocks the creation of these functions in a dictionary-like router (from what I can tell)
Which project does this relate to?
Start
Describe the bug
Hi all, I'm running into an error with TanStack Start - Internal server error: createServerFn must be assigned to a variable!
My basic use case is trying to convert from a tRPC project, in which I really enjoy to DX of defining all of my APIs and then it's as simple as calling trpc..useQuery(param) in a component and you can rock from there
I understand how to create serverFns in Start and use them in components, and have also plugged in TanStack Router to handle some of this in components. My issue is that it can become a little verbose in using these serverFns in client components, like this: (just for example, specifics don't matter too much here)
I'm trying to re-create tRPC-like functionality in TanStack Start, and have some code below to start it - but then I run in to the error in the title: "Internal server error: createServerFn must be assigned to a variable!"
Is there any way to get full type-awareness, plus TanStack Query functionality, with reducing verbosity?
There was a similar convo on the Discord, but didn't help me get fully there - https://discord.com/channels/719702312431386674/1322986702553223288
Your Example Website or App
none
Steps to Reproduce the Bug or Issue
Detailed in description
Expected behavior
Detailed in description
Screenshots or Videos
No response
Platform
Detailed in description
Additional context
No response
The text was updated successfully, but these errors were encountered: