Skip to content

Commit ac821f4

Browse files
authored
docs(start): clarify server functions vs server routes (#7651)
* docs(start): clarify server functions and routes usage * clean up repetition
1 parent f23ed0f commit ac821f4

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎docs/start/framework/react/guide/server-functions.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const time = await getServerTime()
2121

2222
Server functions provide server capabilities (database access, environment variables, file system) while maintaining type safety across the network boundary.
2323

24+
> [!NOTE]
25+
> Server functions are meant to be called by your TanStack Start application. They are easy to use from your app code, and Start handles serialization across the client/server boundary. If you need an endpoint that can be called from outside your Start app, use [server routes](./server-routes) instead.
26+
2427
## Same-Origin Requests
2528

2629
Server functions are same-origin RPC endpoints for your application. Browser requests to server functions should come from the same origin, verified with Fetch Metadata (`Sec-Fetch-Site`), `Origin`, or `Referer` headers. Use server routes for public APIs or endpoints that intentionally support cross-origin requests.

‎docs/start/framework/react/guide/server-routes.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export const Route = createFileRoute('/hello')({
2424
})
2525
```
2626

27+
> [!NOTE]
28+
> Server routes are meant for HTTP endpoints that need to be called from outside your TanStack Start application. If you only need to call server-side logic from within your Start app and want Start to handle serialization for you, use [server functions](./server-functions) instead.
29+
2730
## Server Routes and App Routes
2831

2932
Because server routes can be defined in the same directory as your app routes, you can even use the same file for both!

0 commit comments

Comments
 (0)