Hooks

useSSRStatus

useSSRStatus() returns information about whether SSR data was used for consent manager initialization. This is primarily useful for debugging SSR data flow in Next.js or other server-rendering frameworks.

import { useSSRStatus } from '@c15t/react';

function DebugSSR() {
  const { ssrDataUsed, ssrSkippedReason } = useSSRStatus();

  if (ssrDataUsed) {
    return <span>Consent initialized from SSR data</span>;
  }

  return <span>SSR skipped: {ssrSkippedReason ?? 'unknown'}</span>;
}

Return Value

Warning: ExtractedTypeTable: Could not extract "SSRStatus" from "./packages/react/src/hooks/use-ssr-status.ts" using base path "/vercel/path0/apps/c15t-docs/.leadtype/c15t". Verify the path/name and that the file is included by your tsconfig.

Loading…

Info

Must be used within a ConsentManagerProvider. Throws if used outside the provider context.