type MatchMediaHydrationContext = Record; type MediaQueryEnvironmentConfig = { all?: true; anyHover?: "none" | "hover"; anyPointer?: "none" | "fine" | "coarse"; aspectRatio?: number; color?: number; colorGamut?: "srgb" | "p3" | "rec2020"; colorIndex?: number; displayMode?: "fullscreen" | "standalone" | "minimal-ui" | "browser" | "window-controls-overlay"; dynamicRange?: "standard" | "high"; forcedColors?: "none" | "active"; grid?: 0 | 1; /** in px */ height?: number; hover?: "none" | "hover"; invertedColors?: "none" | "inverted"; monochrome?: number; orientation?: "portrait" | "landscape"; overflowBlock?: "none" | "scroll" | "optional-paged" | "paged"; overflowInline?: "none" | "scroll"; pointer?: "none" | "fine" | "coarse"; prefersColorScheme?: "no-preference" | "light" | "dark"; prefersContrast?: "no-preference" | "more" | "less"; prefersReducedMotion?: "no-preference" | "reduce"; print?: true; /** in dpi */ resolution?: number; screen?: true; scripting?: "none" | "initial-only" | "enabled"; update?: "none" | "slow" | "fast"; videoDynamicRange?: "standard" | "high"; /** in px */ width?: number; prefersReducedTransparency?: "no-preference" | "reduce"; lightLevel?: "dim" | "normal" | "washed"; }; /** * Configures the Node environment for server-side rendering (SSR). * * This function is used to set up the environment for the `useMatchMedia` hook * when running React components on the server. It allows you to provide a custom * configuration object to simulate different media query results. * * The configuration object should contain properties that match the media query conditions * you want to simulate. For example, if you configure it with `{ width: 768 }`, it will * simulate the viewport width as if it were 768 pixels wide, affecting the results returned * by `useMatchMedia` when evaluating media queries related to width. * * @param config - The configuration object for the environment. * @returns The context object to be used with the `MatchMediaHydrationProvider`. * * @example * ```jsx * import { * useMatchMedia, * configureNodeEnv, * MatchMediaHydrationProvider, * } from "react-hook-media"; * * const MyComponent = () => { * const isDesktop = useMatchMedia("(min-width: 900px)"); * * return
{isDesktop ? "This is desktop" : "This is mobile"}
; * }; * * const IndexPage = ({ mediaHydrationCtx }) => ( * * * * ); * * export const getServerSideProps = async () => { * return { * props: { * mediaHydrationCtx: configureNodeEnv({ width: 1000 }), * }, * }; * }; * ``` */ declare const configureNodeEnv: (config: MediaQueryEnvironmentConfig) => MatchMediaHydrationContext; export { type MatchMediaHydrationContext, type MediaQueryEnvironmentConfig, configureNodeEnv as default };