/** * TinyConsent React - Cookie Consent Banner Component * * A thin React component for loading TinyConsent cookie banners. * Does NOT contain any internal TinyConsent logic - only renders the script tag. * * Generate your script at: https://tinyconsent.com/cookie-banner-generator * * @packageDocumentation */ /** * Props for the TinyConsentScript component */ interface TinyConsentScriptProps { /** * Your unique TinyConsent script ID * Get one at: https://tinyconsent.com/cookie-banner-generator */ id: string; /** * Whether to load the script asynchronously (default: true) */ async?: boolean; /** * Whether to defer script execution (default: false) */ defer?: boolean; /** * Callback when the script has loaded */ onLoad?: () => void; /** * Callback if the script fails to load */ onError?: (error: Error) => void; /** * Additional nonce for CSP (Content Security Policy) */ nonce?: string; } /** * React component that renders the TinyConsent cookie banner script tag. * * This component renders: * ```html * * ``` * * @example * ```tsx * import { TinyConsentScript } from 'tinyconsent-react'; * * function App() { * return ( * <> * *
My App Content
* * ); * } * ``` * * @example * ```tsx * // With callbacks * console.log('Banner loaded!')} * onError={(err) => console.error('Failed:', err)} * /> * ``` * * @see https://tinyconsent.com/cookie-banner-for-react - React integration guide * @see https://tinyconsent.com/cookie-banner-generator - Generate your script ID */ declare function TinyConsentScript({ id, async: asyncProp, defer, onLoad, onError, nonce, }: TinyConsentScriptProps): JSX.Element | null; /** * Hook result for useTinyConsent */ interface UseTinyConsentResult { /** * Whether the script is currently loading */ isLoading: boolean; /** * Whether the script has loaded successfully */ isLoaded: boolean; /** * Any error that occurred during loading */ error: Error | null; } /** * React hook for loading the TinyConsent cookie consent banner. * * Use this hook when you need programmatic control over the loading state, * or when you can't use the TinyConsentScript component directly. * * @param scriptId - Your unique TinyConsent script ID * @returns Object containing loading state, loaded state, and any error * * @example * ```tsx * import { useTinyConsent } from 'tinyconsent-react'; * * function App() { * const { isLoading, isLoaded, error } = useTinyConsent('your-script-id'); * * if (error) { * console.error('Cookie banner failed to load:', error); * } * * return
My App
; * } * ``` * * @see https://tinyconsent.com/cookie-banner-for-react - React integration guide */ declare function useTinyConsent(scriptId: string): UseTinyConsentResult; /** * Generates the TinyConsent script URL for a given script ID. * * @param scriptId - Your unique TinyConsent script ID * @returns The full URL to the TinyConsent script * * @example * ```typescript * import { getTinyConsentScriptUrl } from 'tinyconsent-react'; * * const url = getTinyConsentScriptUrl('your-script-id'); * // 'https://scripts.tinyconsent.com/api/scripts/your-script-id' * ``` */ declare function getTinyConsentScriptUrl(scriptId: string): string; export { TinyConsentScript, type TinyConsentScriptProps, type UseTinyConsentResult, TinyConsentScript as default, getTinyConsentScriptUrl, useTinyConsent };