@@ -3,9 +3,10 @@ description: |
33 What types can be passed as island props, how Fresh serializes data between server and client, and common pitfalls.
44---
55
6- When Fresh renders a page on the server, island props must be serialized to JSON
7- and sent to the browser for hydration. Fresh uses a custom serialization system
8- that supports more types than standard ` JSON.stringify ` .
6+ When Fresh renders a page on the server, [ island] ( /docs/concepts/islands ) props
7+ must be serialized to JSON and sent to the browser for hydration. Fresh uses a
8+ custom serialization system that supports more types than standard
9+ ` JSON.stringify ` .
910
1011## Supported types
1112
@@ -25,25 +26,25 @@ The following types can be passed as island props:
2526| ` Set ` | Values must be serializable |
2627| ` Map ` | Keys and values must be serializable |
2728| ` Uint8Array ` | Binary data |
28- | ` Signal ` | From ` @preact/signals ` — see [ Signals] ( /docs/concepts/signals ) |
29+ | ` Signal ` | From ` @preact/signals ` - see [ Signals] ( /docs/concepts/signals ) |
2930| ` Computed Signal ` | Read-only signals |
3031| JSX Elements | Server-rendered JSX passed to islands |
3132
3233## Not serializable
3334
3435The following ** cannot** be passed as island props:
3536
36- - ** Functions and closures** — there is no way to transfer executable code
37- - ** Class instances** — only plain objects are supported (no custom prototypes)
38- - ** Symbols** — not representable in JSON
39- - ** WeakMap / WeakSet** — cannot be enumerated
40- - ** Streams, Promises** — async values cannot be frozen for transfer
37+ - ** Functions and closures** - there is no way to transfer executable code
38+ - ** Class instances** - only plain objects are supported (no custom prototypes)
39+ - ** Symbols** - not representable in JSON
40+ - ** WeakMap / WeakSet** - cannot be enumerated
41+ - ** Streams, Promises** - async values cannot be frozen for transfer
4142
4243``` tsx
43- // WRONG — functions cannot be serialized
44+ // WRONG - functions cannot be serialized
4445<MyIsland onClick = { () => console .log (" clicked" )} />
4546
46- // WRONG — class instance loses its prototype
47+ // WRONG - class instance loses its prototype
4748<MyIsland data = { new MyCustomClass ()} />
4849```
4950
@@ -70,7 +71,7 @@ When a `Signal` is detected in island props:
7071 reactive signal
7172
7273If the same signal object is passed to multiple islands, it is serialized once
73- and all islands receive the same signal instance on the client — keeping them
74+ and all islands receive the same signal instance on the client - keeping them
7475synchronized.
7576
7677Computed signals are serialized by reading their current value and wrapping it
@@ -96,5 +97,5 @@ runtime error during serialization. Keep island props to plain data:
9697### Large props
9798
9899Every byte of serialized props is embedded in the HTML and parsed on the client.
99- Keep island props small — pass IDs or minimal data, and fetch the rest
100+ Keep island props small - pass IDs or minimal data, and fetch the rest
100101client-side if needed.
0 commit comments