Skip to content

Commit 02f1439

Browse files
committed
docs(solid-start): serialization adapters
1 parent 52d39ab commit 02f1439

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/start/framework/solid/guide/server-functions.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,28 @@ replace:
77
'@tanstack/react-router': '@tanstack/solid-router',
88
}
99
---
10+
11+
### Custom serialization adapters
12+
13+
You can create custom serialization adapters to handle complex types that can't be serialized by default.
14+
15+
Example:
16+
17+
```ts
18+
// src/start.ts
19+
import { createStart } from '@tanstack/solid-start'
20+
import { createSerializationAdapter } from '@tanstack/solid-router'
21+
22+
const bigIntAdapter = createSerializationAdapter({
23+
key: 'bigint',
24+
test: (value: unknown): value is bigint => typeof value === 'bigint',
25+
toSerializable: (bigInt) => bigInt.toString(),
26+
fromSerializable: (value) => BigInt(value),
27+
})
28+
29+
export const startInstance = createStart(() => {
30+
return {
31+
serializationAdapters: [bigIntAdapter],
32+
}
33+
})
34+
```

0 commit comments

Comments
 (0)