UNPKG

solobase-js

Version:

A 100% drop-in replacement for the Supabase JavaScript client. Self-hosted Supabase alternative with complete API compatibility.

92 lines 3.46 kB
export { SolobaseClient } from './SolobaseClient.js'; export type * from './types/index.js'; import { SolobaseClient } from './SolobaseClient.js'; import { SolobaseClientOptions } from './types/index.js'; /** * Create a new Solobase client * * This is a 100% drop-in replacement for Supabase's createClient function. * Simply replace your Supabase import with this and everything will work the same. * * @example * ```js * // Instead of: * // import { createClient } from '@supabase/supabase-js' * // const supabase = createClient('https://your-project.supabase.co', 'your-anon-key') * * // Use: * import { createClient } from 'solobase-js' * const solobase = createClient('https://your-solobase.com', 'your-api-key') * * // All the same APIs work: * const { data, error } = await solobase.from('users').select('*') * const { data: user } = await solobase.auth.getUser() * const { data: uploadData } = await solobase.storage.from('avatars').upload('file.png', file) * ``` * * @param baseUrl - Your Solobase project URL * @param apikey - Your project's API key * @param options - Additional client options */ export declare function createClient(baseUrl: string, apikey: string, options?: SolobaseClientOptions): SolobaseClient; /** * Create a new Solobase client for server-side rendering (SSR) * * This function creates a client that works in server environments and supports * cookie-based session management, exactly like Supabase's createServerClient. * * @example * ```js * // Next.js middleware example: * import { createServerClient } from 'solobase-js' * import { NextResponse } from 'next/server' * * export async function middleware(request) { * let response = NextResponse.next({ request }) * * const solobase = createServerClient( * process.env.NEXT_PUBLIC_SOLOBASE_URL, * process.env.NEXT_PUBLIC_SOLOBASE_ANON_KEY, * { * cookies: { * getAll() { * return request.cookies.getAll() * }, * setAll(cookiesToSet) { * cookiesToSet.forEach(({ name, value, options }) => { * request.cookies.set(name, value) * }) * response = NextResponse.next({ request }) * cookiesToSet.forEach(({ name, value, options }) => * response.cookies.set(name, value, options) * ) * }, * }, * } * ) * * const { data: { user } } = await solobase.auth.getUser() * * if (!user && request.nextUrl.pathname.startsWith('/dashboard')) { * return NextResponse.redirect(new URL('/login', request.url)) * } * * return response * } * ``` * * @param baseUrl - Your Solobase project URL * @param apikey - Your project's API key * @param options - Additional client options including cookie management */ export declare function createServerClient(baseUrl: string, apikey: string, options: SolobaseClientOptions & { cookies: import('./types/index.js').CookieMethods; }): SolobaseClient; export { SolobaseAuthClient } from './SolobaseAuthClient.js'; export { SolobaseQueryBuilder, SolobaseFilterBuilder } from './SolobaseQueryBuilder.js'; export { SolobaseStorageClient } from './SolobaseStorageClient.js'; export { SolobaseRealtimeClient, SolobaseRealtimeChannel } from './SolobaseRealtimeClient.js'; export { SolobaseFetch } from './lib/fetch.js'; export declare const version = "1.0.3"; export default createClient; //# sourceMappingURL=index.d.ts.map