diff --git a/docs/start/framework/react/guide/server-functions.md b/docs/start/framework/react/guide/server-functions.md index 2cbbdf0dde..d9fd667f48 100644 --- a/docs/start/framework/react/guide/server-functions.md +++ b/docs/start/framework/react/guide/server-functions.md @@ -270,6 +270,31 @@ export default defineConfig({ }) ``` +### Custom serialization adapters + +You can create custom serialization adapters to handle complex types that can't be serialized by default. + +Example: + +```ts +// src/start.ts +import { createStart } from '@tanstack/react-start' +import { createSerializationAdapter } from '@tanstack/react-router' + +const bigIntAdapter = createSerializationAdapter({ + key: 'bigint', + test: (value: unknown): value is bigint => typeof value === 'bigint', + toSerializable: (bigInt) => bigInt.toString(), + fromSerializable: (value) => BigInt(value), +}) + +export const startInstance = createStart(() => { + return { + serializationAdapters: [bigIntAdapter], + } +}) +``` + --- > **Note**: Server functions use a compilation process that extracts server code from client bundles while maintaining seamless calling patterns. On the client, calls become `fetch` requests to the server.