import React from "react"; /** Router state exposed through `useRouter()`. */ export interface RouterValue { /** Active domain for the current route. */ domain: string; /** Full current path including the pathname. */ path: string; /** Current URL pathname. */ pathname: string; /** Route parameters matched from the current route. */ params: Record; /** Query parameters for the current URL. */ query: Record; /** Whether the route is rendered in preview mode. */ isPreview: boolean; /** Whether the client router is mounted. */ isMounted: boolean; /** Navigate to a URL using the active router. */ navigate: (url: string) => Promise; /** Push a new URL onto the history stack. */ push: (url: string) => Promise; /** Replace the current history entry with a URL. */ replace: (url: string) => Promise; /** Reload the current route. */ reload: () => Promise; } /** Props accepted by ``. */ export type LinkProps = React.AnchorHTMLAttributes & { /** Enable Veryfront prefetch handling for this link. */ prefetch?: boolean; }; /** Props accepted by ``. */ export interface RouterProviderProps { /** React children rendered within the router context. */ children: React.ReactNode; /** * The router snapshot. On the server it is exposed verbatim. On the client it * seeds `params`/`domain`/`isPreview` and the initial `pathname`/`query` — the * server-render snapshot the first client render must match — after which * `pathname`/`query` track the live URL through the navigation store. * * This is the single source for everything the URL and route match know; * callers hand over one `RouterValue` rather than loose href/param fields. */ router?: RouterValue; } /** Heading metadata extracted from MDX content. */ export interface MdxHeading { /** Visible heading text. */ text: string; /** Stable heading anchor ID. */ id: string; /** Heading level from 1 to 6. */ level: number; } /** Page context exposed to route and MDX components. */ export interface PageContextValue { /** Route slug for the current page. */ slug: string; /** Current route path. */ path: string; /** Dynamic route parameters. */ params: Record; /** Query parameters for the current URL. */ query: Record; /** Parsed page frontmatter. */ frontmatter: Record; /** * Props returned by the page's `getServerData` (the object under its * `props` key). Exposed here so layouts and nested components can read * server data without prop-drilling from the page. Empty object when the * page has no `getServerData`. Populated identically on the server render, * the hydration seed, and client navigation. */ data: Record; /** Headings discovered in the page content. */ headings: MdxHeading[]; /** MDX headings discovered in the page content. */ mdxHeadings: MdxHeading[]; } /** * Input accepted by {@link PageContextProvider}. `data` (the page's * `getServerData` props) is optional here so seeds built before the field * existed keep compiling; the provider merges the seed over * {@link defaultPageContext}, so an omitted field surfaces as its documented * empty default rather than `undefined`. */ export type PageContextSeed = Omit & { data?: Record; }; /** Props accepted by ``. */ export interface PageContextProviderProps { /** React children rendered within the page context. */ children: React.ReactNode; /** Page context seed to expose to descendants. */ pageContext?: PageContextSeed; } /** How a navigation should affect the history stack. */ type HistoryMode = "push" | "replace" | "none"; /** Options accepted by the navigation store's `navigate`. */ interface NavigateOptions { history?: HistoryMode; } /** * The cross-bundle navigation store the client router and this React runtime * share. This is an inline mirror of `rendering/client/navigation-store.ts`, * kept here so the public React runtime bundle does not import the rendering * layer. The shared `Symbol.for` key guarantees both bundles resolve the *same* * runtime object regardless of which one evaluates first — so `RouterProvider` * can subscribe synchronously on its first render, with no boot-order race. */ interface NavigationStore { subscribe(listener: () => void): () => void; getHref(): string; notify(): void; navigate(href: string, options?: NavigateOptions): Promise; setNavigator(navigator: (href: string, options?: NavigateOptions) => Promise): void; } export declare function getNavigationStore(): NavigationStore; /** * Provides the router context. `pathname`/`query` track the live URL through the * shared navigation store's `useSyncExternalStore` surface; `params`/`domain` * are seeded from the `router` prop. One component serves both sides: React uses * `getServerSnapshot` (the seed href) during SSR and the live store on the * client, so there is no environment branch — the server render and the first * client render match by construction. * * The store is a stable singleton that exists on first access, so there is no * "is the router mounted yet?" race: the subscription is live from the first * render, and the router's navigations notify through the same object. Page * context (frontmatter/slug/headings) is a separate concern, provided by * `PageContextProvider`, which derives its live location from this router. */ export declare function RouterProvider({ router, children }: RouterProviderProps): React.ReactElement; /** Options for {@link wrapForHydration}. */ export interface HydrationWrapOptions { /** Route params from the initial match. */ params?: Record; /** Page frontmatter, exposed reactively through `usePageContext()`. */ frontmatter?: Record; /** * Props returned by the page's `getServerData`, exposed as * `usePageContext().data`. Seeded here so a hydrated client tree under an * App/RSC page reads the same server data the server render saw, instead of * an empty object. */ data?: Record; } /** * Wraps a hydrated client component in `RouterProvider` (router state) nested * with `PageContextProvider` (frontmatter), seeded from the live location plus * the initial route match — mirroring how SSR wraps the tree. * * The RSC hydration path calls this through a runtime import of * `veryfront/router`, so it runs under the app's React instance — the same one * the hydrated component uses, and the same providers and `React` this module * already reference. That is why the caller does not (and must not) pass a * `React` across the module boundary: the wrapping happens here, inside the * module that owns React. */ export declare function wrapForHydration(child: React.ReactNode, options?: HydrationWrapOptions): React.ReactElement; /** * Reads the router context: `pathname`, `query`, `params`, and the navigation * actions. Reactive across client-side navigation — this is the single hook for * location and navigation state. */ export declare function useRouter(): RouterValue; /** Renders an anchor element annotated for Veryfront prefetch handling. */ export declare function Link({ prefetch, children, ...rest }: LinkProps): React.ReactElement; /** * Provides page context to route and MDX descendants. Page-authored fields * (`frontmatter`, `slug`, `headings`) come from the `pageContext` prop; the * location fields (`path`, `query`, `params`) are derived from the router so * they stay reactive and there is a single source of truth — `usePageContext()` * exposes the same `query`/`pathname` as `useRouter()`. When rendered outside a * `RouterProvider` (no live router) it falls back to the seed's own location. */ export declare function PageContextProvider({ children, pageContext, }: PageContextProviderProps): React.ReactElement; /** Reads the current page context. */ export declare function usePageContext(): PageContextValue; /** Applies document head elements during SSR and client rendering. */ export declare function Head({ children }: { children: React.ReactNode; }): React.ReactElement; export { RouterProvider as Router }; //# sourceMappingURL=core.d.ts.map