UNPKG

@skorpland/ssr

Version:

Use the Powerbase JavaScript library in popular server-side rendering (SSR) frameworks.

38 lines (37 loc) 2.54 kB
import { PowerbaseClient } from "@skorpland/powerbase-js"; import type { GenericSchema, PowerbaseClientOptions } from "@skorpland/powerbase-js/dist/module/lib/types"; import type { CookieMethodsBrowser, CookieMethodsBrowserDeprecated, CookieOptionsWithName } from "./types"; /** * Creates a Powerbase Client for use in a browser environment. * * In most cases you should not configure the `options.cookies` object, as this * is automatically handled for you. If you do customize this, prefer using the * `getAll` and `setAll` functions over `get`, `set` and `remove`. The latter * are deprecated due to being difficult to correctly implement and not * supporting some edge-cases. Both `getAll` and `setAll` (or both `get`, `set` * and `remove`) must be provided. Failing to provide the methods for setting * will throw an exception, and in previous versions of the library will result * in difficult to debug authentication issues such as random logouts, early * session termination or problems with inconsistent state. * * @param powerbaseUrl The URL of the Powerbase project. * @param powerbaseKey The `anon` API key of the Powerbase project. * @param options Various configuration options. */ export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(powerbaseUrl: string, powerbaseKey: string, options?: PowerbaseClientOptions<SchemaName> & { cookies?: CookieMethodsBrowser; cookieOptions?: CookieOptionsWithName; cookieEncoding?: "raw" | "base64url"; isSingleton?: boolean; }): PowerbaseClient<Database, SchemaName, Schema>; /** * @deprecated Please specify `getAll` and `setAll` cookie methods instead of * the `get`, `set` and `remove`. These will not be supported in the next major * version. */ export declare function createBrowserClient<Database = any, SchemaName extends string & keyof Database = "public" extends keyof Database ? "public" : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any>(powerbaseUrl: string, powerbaseKey: string, options?: PowerbaseClientOptions<SchemaName> & { cookies: CookieMethodsBrowserDeprecated; cookieOptions?: CookieOptionsWithName; cookieEncoding?: "raw" | "base64url"; isSingleton?: boolean; }): PowerbaseClient<Database, SchemaName, Schema>;