@optare/client
v0.1.0
Published
Headless, framework-agnostic client SDK for Optare. Takes a pk_live_ key and resolves endpoint + branding.
Readme
@optare/client
Headless, framework-agnostic client SDK for Optare. The entire integration
contract is one string — a publishable key (pk_live_…).
import { createOptareClient } from "@optare/client";
const { auth, config } = await createOptareClient({
publishableKey: "pk_live_xxx",
// baseURL / configURL optional — defaults to the hosted Optare API
});
// `auth` is a better-auth client
await auth.signIn.email({ email, password });
const { data: session } = await auth.getSession();
// `config` is the resolved endpoint + white-label branding
config.baseURL; // where the auth API lives
config.branding.name; // customer's org name
config.branding.logoUrl; // customer's logoWhat it does
resolveOptareConfig()callsGET /api/public/config?pk=…and learns the auth API origin and the project's branding.pk_live_is not a secret, so this is safe from a browser.createOptareClient()builds a better-auth client pointed at that origin with the Optare plugin set (organization, 2FA, email OTP, magic link, multi-session, JWT) and the publishable key attached to every request.
For SSR, call resolveOptareConfig() on the server and pass the result back as
bootstrap to skip the client-side fetch.
Server-side use
For sk_live_ management calls or offline JWT verification, use
@optare/node instead — this package is for the front end.
