Skip to content
Source
Sign inSign up
TanStack/router

Add support for customizable `functionId` generation. #5373

Mergedzenios(GitHub profile, opens in a new tab)merged 12 commits intomain fromrefs/pull/5373/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Showing 12 changed files with 61 additions and 3 deletions (loading 8).

x
0 of 12 viewed, 12 left
46 additions and 0 deletionsdocs/start/framework/react/server-functions.mdModified
View file
@@ -224,6 +224,52 @@
​
Handle request cancellation with `AbortSignal` for long-running operations.
​
+### Function ID generation
+​
+Server functions are addressed by a generated, stable function ID under the hood. These IDs are embedded into the client/SSR builds and used by the server to locate and import the correct module at runtime.
+​
+Defaults:
+​
+- In development, IDs are URL-safe strings derived from `${filename}--${functionName}` to aid debugging.
+- In production, IDs are SHA256 hashes of the same seed to keep bundles compact and avoid leaking file paths.
+- If two server functions end up with the same ID (including when using a custom generator), the system de-duplicates by appending an incrementing suffix like `_1`, `_2`, etc.
+- IDs are stable for a given file/function tuple for the lifetime of the process (hot updates keep the same mapping).
+​
+Customization:
+​
+You can customize function ID generation by providing a `generateFunctionId` function when configuring the TanStack Start Vite plugin:
+​
+Example:
+​
+```ts
+// vite.config.ts
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'