Are there documentation examples for server functions?
I feel like I'm misunderstanding something, as replicating the
getServerTime
example from https://tanstack.com/router/latest/docs/framework/react/start/server-functions#server-function-context triggers a Invariant failed: createServerFn must be called with a function that is marked with the 'use server' pragma.
error.
Is there an example app somewhere in the docs showing the correct use of server functions?
For context, I'm calling getServerTime from a react hook. My hope is to write a darkMode cookie eventually!Server Functions | TanStack Router React Docs
What are Server Functions? Server functions allow you to specify logic that can be invoked almost anywhere (even the client), but run only on the server. In fact, they are not so different from an API...
1 Reply
useful-bronze•9mo ago
Could you give us an example? And also a stack trace.