Parameters
The Svelte component to hydrate
Configuration options for hydrating the component
Target element containing the server-rendered HTML
Component properties. Required if the component expects props
Whether or not to play transitions on initial hydration. Defaults to
false (unlike mount())Can be accessed via
getContext() at the component levelAllows the specification of events. Use callback props instead
If
false, throws an error when hydration fails instead of falling back to client-side renderingA function that transforms errors caught by error boundaries before they are passed to the
failed snippet. Defaults to the identity functionReturns
The component’s exports (and potentially the props if compiled with
accessors: true)Examples
Basic hydration
Hydration with intro transitions
Strict hydration mode
With context
Hydration behavior
- By default,
hydrate()looks for a comment node<!--ssr:start-->in the target element to know where to begin hydration - If hydration fails (e.g., due to a mismatch between server and client output), Svelte will log a warning and fall back to client-side rendering (unless
recover: falseis set) - Unlike
mount(), the default value forintroisfalseto avoid playing transitions on already-rendered content - The target element should contain the HTML that was rendered on the server
Notes
- Server-side rendering must produce hydration markers for
hydrate()to work correctly - Hydration mismatches can occur if the component’s initial state differs between server and client
- For optimal performance, ensure props passed during hydration match those used during server-side rendering
- See the server-side rendering guide for more information