@cdr-kit/react/Hooks/useStorageBackend

useStorageBackend

Config-driven CdrStorageProvider factory. A dashboard switches backends at runtime by passing a JSON config (Pinata / Supabase / IPFS / read-only gateway / in-memory).
import { useStorageBackend } from "@cdr-kit/react"

Signature

type
type StorageBackendConfig =
| { kind: "memory" }
| { kind: "pinata"; jwt: string; gatewayUrl?: string }
| { kind: "supabase"; supabaseUrl: string; key: string; bucket: string;
    pathPrefix?: string; bucketIsPublic?: boolean }
| { kind: "gateway"; gatewayUrl: string }
| { kind: "ipfs"; addUrl: string; gatewayUrl: string;
    headers?: Record<string, string> };

function useStorageBackend(config: StorageBackendConfig | undefined): CdrStorageProvider | undefined;

Memoization

The provider instance is memoized on config identity. Pass a stable config object (typically from your environment variables, not a fresh literal every render).