UNPKG

@edgestore/react

Version:

Upload files with ease from React/Next.js

65 lines 2.16 kB
import { type AnyRouter } from '@edgestore/shared'; import * as React from 'react'; import { type BucketFunctions } from './createNextProxy'; type EdgeStoreContextValue<TRouter extends AnyRouter> = { edgestore: BucketFunctions<TRouter>; /** * This will re-run the EdgeStore initialization process, * which will run the `createContext` function again. * * Can be used after a sign-in or sign-out, for example. */ reset: () => Promise<void>; /** * The current state of the EdgeStore provider. * * You can use this to wait for the provider to be initialized * before trying to show private images on your app. */ state: ProviderState; }; export declare function createEdgeStoreProvider<TRouter extends AnyRouter>(opts?: { /** * The maximum number of concurrent uploads. * * Uploads will automatically be queued if this limit is reached. * * @default 5 */ maxConcurrentUploads?: number; /** * Accessing EdgeStore protected files in development mode requires a proxy. * You might want to disable this for other providers if you are overwriting the path. * * @default false */ disableDevProxy?: boolean; }): { EdgeStoreProvider: ({ children, basePath, }: { children: React.ReactNode; /** * In case your app is not hosted at the root of your domain, you can specify the base path here. * If you set this, make sure to set the full path to the EdgeStore API. * e.g. `/my-app/api/edgestore` or `https://example.com/my-app/api/edgestore` * * @example - If your app is hosted at `https://example.com/my-app`, you can set the `basePath` to `/my-app/api/edgestore`. */ basePath?: string; }) => React.JSX.Element; useEdgeStore: () => EdgeStoreContextValue<TRouter>; }; type ProviderState = { loading: true; initialized: false; error: false; } | { loading: false; initialized: false; error: true; } | { loading: false; initialized: true; error: false; }; export {}; //# sourceMappingURL=contextProvider.d.ts.map