🔍⌘K

Start typing to search docs.

Forge Apps SDK

1.0.0

Hooks and utilities from common/lib/forgeapps-sdk for Supabase access.

Web client hooks

import { useSupabaseClient, useSession } from '@app-factory/forgeapps-sdk/web';

const supabase = useSupabaseClient();
const session = useSession();
  • useSupabaseClient wraps the Supabase client with cookie/session handling.
  • useSession subscribes to auth changes and proxies Supabase session events to React.

Server utilities

import { createServiceRoleClient } from '@app-factory/forgeapps-sdk/server';

const supabase = await createServiceRoleClient();
const { data } = await supabase.from('demo_app_users').select('*');
  • Server helpers load service role keys via config resolution.
  • Use them for API routes, webhooks, and background jobs.

Organization utilities

import { ensureOrganization } from '@app-factory/forgeapps-sdk/organizations';

const org = await ensureOrganization({
  userId: session.user.id,
  suggestedName: 'Acme Co',
});
  • Creates or returns the user’s primary organization.
  • Works with the cookie helpers in apps/landing/src/lib/session.ts to keep the dashboard + landing app in sync.

Storage helpers

View
import { uploadAsset } from '@app-factory/forgeapps-sdk/storage';

await uploadAsset({
  bucket: 'app-assets',
  file: File,
  path: 'demo-app/logo.png',
});

Warning

Service role helpers should stay on the server only. Client apps should rely on Supabase row-level security and anon keys.