import type { ConnectionStatus, GrantPayload } from "../core/types.js"; /** * Configuration for the {@link useVanaData} hook. */ export interface UseVanaDataConfig { /** URL of the connect API route (default: `"/api/connect"`). */ connectUrl?: string; /** URL of the data API route (default: `"/api/data"`). */ dataUrl?: string; /** Polling interval in ms passed to {@link useVanaConnect} (default: 2000). */ pollingInterval?: number; /** SDK environment passed through to {@link useVanaConnect}. */ environment?: "dev" | "prod"; /** When true, automatically fetches data after grant approval (default: `true`). */ autoFetch?: boolean; } /** * Return value of the {@link useVanaData} hook. */ export interface UseVanaDataResult { /** Current connection status. */ status: ConnectionStatus; /** Grant payload after user approval, or `null`. */ grant: GrantPayload | null; /** Fetched data after calling the data route, or `null`. */ data: unknown; /** Error message, or `null`. */ error: string | null; /** URL to account.vana.org where the user signs in and launches Data Connect, or `null`. */ connectUrl: string | null; /** Opens the connect URL in a new tab. Use this instead of rendering the URL directly to avoid navigating away from your app. */ openConnect: () => void; /** Starts the connect flow by calling the connect API route. */ initConnect: () => Promise; /** Manually fetches data using the current grant. */ fetchData: () => Promise; /** Resets all state back to idle. */ reset: () => void; /** `true` while any async operation is in progress. */ isLoading: boolean; /** `true` when status is `"approved"`. */ isConnected: boolean; } /** * @deprecated For current Account browser approval, use `useDirectVanaConnect` * from `@opendatalabs/vana-sdk/react`. This hook uses legacy Session Relay. * * Full-flow hook that orchestrates the entire Vana Connect lifecycle: * session init, polling, and data fetching. * * Composes {@link useVanaConnect} internally and adds automatic * calls to your app's `/api/connect` and `/api/data` routes. * * @param config - Optional configuration. * @returns A {@link UseVanaDataResult} with state and actions. * * @example * ```tsx * import { useVanaData } from "vana-cli/react"; * * function MyComponent() { * const { status, data, deepLinkUrl, initConnect, isLoading } = useVanaData(); * * if (status === "idle") return ; * if (status === "waiting") return Open Vana; * if (data) return
{JSON.stringify(data, null, 2)}
; * return

{isLoading ? "Loading..." : status}

; * } * ``` */ export declare function useVanaData(config?: UseVanaDataConfig): UseVanaDataResult; //# sourceMappingURL=useVanaData.d.ts.map