UNPKG

@vercel/microfrontends

Version:

Defines configuration and utilities for microfrontends development

48 lines (43 loc) 2.13 kB
import * as react from 'react'; import react__default, { AnchorHTMLAttributes } from 'react'; import { LinkProps as LinkProps$1 } from 'next/link.js'; interface BaseProps { children: React.ReactNode; href: string; } interface NextLinkProps extends LinkProps$1 { } type LinkProps = BaseProps & Omit<NextLinkProps, keyof BaseProps> & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseProps>; declare function useZoneForHref(href: LinkProps['href'] | undefined): { zoneOfHref: string | null; isDifferentZone: boolean; isLoading: boolean; }; /** * A Link component that works with microfrontend set-ups and will prefetch the * cross zone links automatically. */ declare const Link: react.ForwardRefExoticComponent<BaseProps & Omit<NextLinkProps, keyof BaseProps> & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseProps> & react.RefAttributes<HTMLAnchorElement>>; interface PrefetchCrossZoneLinksContext { prefetchHref: (href: string) => void; } declare const PrefetchCrossZoneLinksContext: react__default.Context<PrefetchCrossZoneLinksContext>; declare function PrefetchCrossZoneLinksProvider({ children, }: { children: react__default.ReactNode; }): JSX.Element | null; interface PrefetchCrossZoneLinksProps { /** * This attributes controls how eager the browser should be in prerendering * cross-zone links. Prerendering downloads the HTML and subresources of the page * and starts to render the page in the background. This consumes more resources * but provides a faster user experience if the user decides to visit that page. * * See https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/speculationrules#eagerness * for more information. * * Default value is 'conservative'. */ prerenderEagerness?: 'immediate' | 'eager' | 'moderate' | 'conservative'; } declare function PrefetchCrossZoneLinks({ prerenderEagerness, }: PrefetchCrossZoneLinksProps): JSX.Element | null; export { Link, LinkProps, PrefetchCrossZoneLinks, PrefetchCrossZoneLinksContext, PrefetchCrossZoneLinksProvider, useZoneForHref };