Class ReadableSSRRouter<Context>

The streaming router that can be used as a transformer for Web Streams. It enqueues router hydration chunks into the after each chunk from the read side.

Type Parameters

Hierarchy (view full)

Implements

  • ReadableWritablePair

Constructors

Methods

  • Instantly aborts the pending route loading for the rootController and its descendants.

    Parameters

    • Optionalreason: unknown

      The abort reason that is used for rejection of the loading promise.

    Returns void

  • Resolves with true if there were pending controllers and their state has changed after they became non-pending. Otherwise, resolves with false.

    Returns Promise<boolean>

  • Returns the array of matched routes and extracted params for a given location.

    Parameters

    • to: To

      The location to match.

    Returns RouteMatch[]

  • Looks up a route in routes that matches a location, loads its data and notifies subscribers.

    Parameters

    • to: To

      A location or a route to navigate to.

    • options: NavigateOptions = {}

      Navigate options.

    Returns void

  • Returns an inline <script> tag with source that hydrates the client with the state accumulated during SSR, or an empty string if there are no state changes since the last time nextHydrationScript was called.

    Returns string

  • Returns a script source that hydrates the client with the state accumulated during SSR, or an empty string if there are no state changes since the last time nextHydrationScript was called.

    Returns string

  • Prefetches components and data of routes matched by a location.

    Parameters

    • to: To

      A location or a route to prefetch.

    Returns AbortablePromise<void>

    An promise that can be aborted to discard prefetching.

  • Subscribes a listener to events published by a router.

    Parameters

    • listener: ((event: RouterEvent) => void)

      A listener to subscribe.

    Returns (() => void)

    A callback that unsubscribe a listener.

      • (): void
      • Returns void

Properties

context: Context

A context provided to route data loaders.

errorComponent: undefined | ComponentType

A component that is rendered when an error was thrown during route rendering.

interceptedController: null | RouteController<any, any, Context> = null

A controller of the intercepted route, or null if there's no intercepted route.

isSSR: boolean = true

true if the router is used in the server environment.

loadingAppearance: undefined | LoadingAppearance

What to render when a component or data are being loaded.

loadingComponent: undefined | ComponentType

A component that is rendered when a route is being loaded.

location: null | Location = null

The location of the latest router navigation.

nonce: undefined | string

A nonce string to allow hydration scripts under a script-src Content-Security-Policy.

notFoundComponent: undefined | ComponentType

A component that is rendered if notFound was called during route loading or rendering

readable: ReadableStream<any>
renderingDisposition: undefined | RenderingDisposition

Where the route is rendered.

rootController: null | RouteController<any, any, Context> = null

A root controller rendered in a router Outlet, or null if there's no matching route or if navigation didn't occur yet.

routes: readonly Route<any, any, any, Context>[]

Routes that a router can render.

writable: WritableStream<any>

Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.

Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.