UNPKG

@vercel/microfrontends

Version:

Defines configuration and utilities for microfrontends development

53 lines (47 loc) 2.08 kB
import * as react from 'react'; import react__default, { AnchorHTMLAttributes } from 'react'; import * as url from 'url'; import { LinkProps as LinkProps$1 } from 'next/link.js'; import { Image as Image$1 } from 'next/dist/client/image-component.js'; interface BaseProps { children: React.ReactNode; href: string; } type LinkProps = BaseProps & Omit<LinkProps$1, 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<{ href: string | url.UrlObject; as?: string | url.UrlObject; replace?: boolean; scroll?: boolean; shallow?: boolean; passHref?: boolean; prefetch?: boolean | null; locale?: string | false; legacyBehavior?: boolean; onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>; onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>; onClick?: React.MouseEventHandler<HTMLAnchorElement>; }, 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; declare function PrefetchCrossZoneLinks(): JSX.Element | null; /** * A Image component that prefixes microfrontend child zones with the asset prefix * to ensure the image request is routed to the correct zone. */ declare const Image: typeof Image$1; export { Image, Link, LinkProps, PrefetchCrossZoneLinks, PrefetchCrossZoneLinksContext, PrefetchCrossZoneLinksProvider, useZoneForHref };