[]previous and next page

HydrateDuskOptions

Options of hydrateDusk.

Options of hydrateDusk.

Import#

ts
import type { HydrateDuskOptions } from "@shadow-js/dusk/client";

Signature#

ts
interface HydrateDuskOptions {
  /**
   * The global error document (`src/routes/_global-error.tsx`). When the app itself fails to mount in the browser, the
   * page is requested again, so the server answers with the global error document. The error goes to `onError`; a second failure in the same session is not retried. Absent: the failure is thrown, as before.
   */
  readonly globalError?: GlobalErrorModule;
  /**
   * The deployment id of the build (the server entry has the same one). Every server function call carries it;
   * a call from another deployment is refused with 409, and the page reloads (see `reloadOnSkew`).
   */
  readonly deploymentId?: string;
  /** Reload the page when a call is refused for another deployment. Default true. */
  readonly reloadOnSkew?: boolean;
  /** The route tree: `routeTree` from the generated `routeTree.gen.ts`. */
  readonly routes: readonly RouteDefinition[];
  /** The app's root component; the same one the server renders. Default: renders its children. */
  readonly App?: DuskAppComponent;
  /**
   * Loads the code of the routes with these ids before the first render, so the markup the
   * browser builds equals the server's. Pass `preloadRoutes` from the generated route tree.
   */
  readonly preload?: (ids: readonly string[]) => Promise<void>;
  /** The element the server rendered the app into, or a selector. Default `#app`. */
  readonly container?: Element | string;
  /** Mount base of the app, the same as the server's (`""` or `/app`). */
  readonly base?: string;
  /** Prefix of the hydration keys; equals the server's `renderId`. Default `"0"`. */
  readonly renderId?: string;
  /**
   * More router options (context, trailing slash policy, pending delays), and the two that are features:
   * `cache` (the loader cache limits) and `viewTransitions` (`true` turns view transitions on).
   * The trailing slash policy inherits the server document unless overridden here.
   */
  readonly router?: Omit<RouterOptions, "routes" | "history" | "base" | "window" | "features"> & {
    readonly cache?: RouterCacheOptions;
    readonly viewTransitions?: boolean;
  };
  /** Load the data of a link's page when the pointer or focus reaches it. Default `true`. */
  readonly prefetch?: boolean;
  /** The route announcer: a client navigation announces the page title and moves focus to the page. Default `true`. */
  readonly announcer?: boolean;
  /** The document to read and hydrate. Default: the global one. */
  readonly document?: Document;
  /** The window for history and events. Default: the global one. */
  readonly window?: Window;
  /** Receives problems that do not stop the page: a payload that cannot be read. Default `console.error`. */
  readonly onError?: (error: unknown) => void;
}

Members#

Name Type Description
globalError? readonly globalError?: GlobalErrorModule The global error document (src/routes/_global-error.tsx). When the app itself fails to mount in the browser, the page is requested again, so the server answers with the global error document. The error goes to onError; a second failure in the same session is not retried. Absent: the failure is thrown, as before.
deploymentId? readonly deploymentId?: string The deployment id of the build (the server entry has the same one). Every server function call carries it; a call from another deployment is refused with 409, and the page reloads (see reloadOnSkew).
reloadOnSkew? readonly reloadOnSkew?: boolean Reload the page when a call is refused for another deployment. Default true.
routes readonly routes: readonly RouteDefinition[] The route tree: routeTree from the generated routeTree.gen.ts.
App? readonly App?: DuskAppComponent The app's root component; the same one the server renders. Default: renders its children.
preload? readonly preload?: (ids: readonly string[]) => Promise<void> Loads the code of the routes with these ids before the first render, so the markup the browser builds equals the server's. Pass preloadRoutes from the generated route tree.
container? readonly container?: Element | string The element the server rendered the app into, or a selector. Default #app.
base? readonly base?: string Mount base of the app, the same as the server's ("" or /app).
renderId? readonly renderId?: string Prefix of the hydration keys; equals the server's renderId. Default "0".
router? readonly router?: Omit<RouterOptions, "routes" | "history" | "base" | "window" | "features"> & { readonly cache?: RouterCacheOptions; readonly viewTransitions?: boolean; } More router options (context, trailing slash policy, pending delays), and the two that are features: cache (the loader cache limits) and viewTransitions (true turns view transitions on). The trailing slash policy inherits the server document unless overridden here.
prefetch? readonly prefetch?: boolean Load the data of a link's page when the pointer or focus reaches it. Default true.
announcer? readonly announcer?: boolean The route announcer: a client navigation announces the page title and moves focus to the page. Default true.
document? readonly document?: Document The document to read and hydrate. Default: the global one.
window? readonly window?: Window The window for history and events. Default: the global one.
onError? readonly onError?: (error: unknown) => void Receives problems that do not stop the page: a payload that cannot be read. Default console.error.