get docs building

elliott/hydratable
Rich Harris 6 days ago
parent f76c1aad7b
commit bc9df88f16

@ -1,5 +1,5 @@
---
title: "`hydratable`"
title: Hydratable data
---
In Svelte, when you want to render asynchonous content data on the server, you can simply `await` it. This is great! However, it comes with a major pitall: when hydrating that content on the client, Svelte has to redo the asynchronous work, which blocks hydration for however long it takes:
@ -65,8 +65,16 @@ By default, Svelte uses [`devalue`](https://npmjs.com/package/devalue) to serial
Encode receives a value and outputs _the JavaScript code necessary to create that value on the client_. For example, Svelte's built-in encoder looks like this:
```ts
const encode = (value) => devalue.uneval(value);
```js
import * as devalue from 'devalue';
/**
* @param {any} value
*/
function encode (value) {
return devalue.uneval(value);
}
encode(['hello', 'world']); // outputs `['hello', 'world']`
```

Loading…
Cancel
Save