import { QueryClient } from "@tanstack/react-query"; import type { AnyRoute, RouterConstructorOptions, RouterHistory, TrailingSlashOption } from "@tanstack/react-router"; import { createRouter } from "@tanstack/react-router"; import { type ComponentType, type ReactElement } from "react"; /** * Router options available to standalone CSR applications. */ export type CreateAppRouterOptions = Record> = Omit, "context" | "routeTree">; /** * Options for creating a standalone or framework-owned SPA runtime. */ export interface CreateAppOptions = Record> { /** The root route tree assembled by application code or generated bootstrap. */ routeTree: TRouteTree; /** * The base path for the application. */ basepath?: string; /** * Optional custom history for the router, such as memory or hash history. */ history?: TRouterHistory; /** TanStack Router options passed through to `createRouter()`. */ router?: CreateAppRouterOptions; /** * Optional custom QueryClient instance. */ queryClient?: QueryClient; } /** Options for mounting or hydrating a standalone application. */ export interface AppRenderOptions { /** Reuse server-rendered DOM after the router's initial data load. */ hydrate?: boolean; } /** Options for handing an Application tree to a framework-owned React root. */ export interface AppComponentOptions { /** Release the component handle when the owning mount session is aborted. */ signal?: AbortSignal; } /** * A rootless Application tree owned by an external React host. * * The host must stop rendering `element`/`Component` before calling `dispose()`. * Creating this handle never calls ReactDOM `createRoot()` or `hydrateRoot()`. */ export interface AppComponentHandle { /** Stable component for hosts that need a component type. */ readonly Component: ComponentType; /** Ready-to-render element backed by the same router, QueryClient, and wrappers as `render()`. */ readonly element: ReactElement; /** Release this Application's component-mode ownership. Idempotent. */ dispose(): void; } /** * An initialized standalone or framework-owned SPA runtime. */ export interface App { /** The TanStack Router instance. */ router: TRouter; /** The TanStack Query Client instance. */ queryClient: QueryClient; /** * Mount the application into the DOM. * @param container - A CSS selector string or an HTMLElement. * @param options - Select hydration when the server already rendered the app. */ render(container: string | HTMLElement, options?: AppRenderOptions): void | Promise; /** * Hand the complete Application React tree to an external root owner without * creating a second DOM root. */ createComponent(options?: AppComponentOptions): AppComponentHandle; /** * Unmount the application from the DOM. */ unmount(): void; } /** * Create a standalone or framework-owned SPA runtime from a route tree. */ export declare function createApp = Record>(options: CreateAppOptions): App>>; //# sourceMappingURL=app.d.ts.map