From 52d39ab157f37d2abc1179e7e779f4eeecdbade5 Mon Sep 17 00:00:00 2001 From: Mathieu Post Date: Thu, 13 Nov 2025 14:59:41 +0100 Subject: [PATCH 1/2] docs(react-start): serialization adapters --- .../framework/react/guide/server-functions.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/start/framework/react/guide/server-functions.md b/docs/start/framework/react/guide/server-functions.md index 2cbbdf0dde6..b2eb913ab02 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. From 02f14390b322e89fc7ac476e3d5c3182ce913547 Mon Sep 17 00:00:00 2001 From: Mathieu Post Date: Tue, 25 Nov 2025 12:08:21 +0100 Subject: [PATCH 2/2] docs(solid-start): serialization adapters --- .../framework/solid/guide/server-functions.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/start/framework/solid/guide/server-functions.md b/docs/start/framework/solid/guide/server-functions.md index 35d8fb58a98..a654b904c0e 100644 --- a/docs/start/framework/solid/guide/server-functions.md +++ b/docs/start/framework/solid/guide/server-functions.md @@ -7,3 +7,28 @@ replace: '@tanstack/react-router': '@tanstack/solid-router', } --- + +### 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/solid-start' +import { createSerializationAdapter } from '@tanstack/solid-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], + } +}) +```