Buildspace

Quick Start (Client)

Initialize the browser SDK with a publishable key.

import { createClient } from "@buildspacestudio/sdk/client";

const bs = createClient(process.env.NEXT_PUBLIC_BUILDSPACE_PUBLISHABLE_KEY!);

The client SDK points at the hosted Buildspace API and login app by default (https://api.buildspace.studio and https://login.buildspace.studio). You only need to pass baseUrl and/or loginUrl when you are targeting a different environment (for example local development or a self-hosted stack):

createClient(key, {
  baseUrl: "https://your-runtime.example",
  loginUrl: "https://your-login.example",
});

Example calls:

const signInUrl = bs.auth.getSignInUrl({ redirectUri: `${window.location.origin}/callback` });
bs.events.track("page:viewed", { path: window.location.pathname });
const upload = await bs.storage.upload(file, { path: `uploads/${file.name}` });