TypeScript SDK

Sign-in and sessions, without the boilerplate

The Anythink SDK is an open source React library for sign-in and sessions: an auth client, a provider, a useAuth hook, and a base class for authenticated requests. Data calls go through the REST API directly — there's no hidden query layer to learn.

Open sourceReactToken refresh handledMulti-tab session isolation

Auth and sessions, handled

The SDK is sign-in and sessions, done properly, so you're not hand-rolling token refresh in every project.

Silent, de-duplicated token refresh

Concurrent requests that hit a 401 don't each fire their own refresh call. AuthenticatedBaseService registers a response interceptor that serialises and caches the refresh, then replays the original requests once it completes.

In practice

The SDK's actual surface

set up the auth client.ts
import { AuthClient } from "@anythink-cloud/sdk";

let authClientInstance: AuthClient | null = null;

export const getAuthClient = (): AuthClient => {
  if (!authClientInstance) {
    authClientInstance = new AuthClient({
      instanceUrl: "https://api.my.anythink.cloud",
      orgId: 12345678,
      storageType: "sessionStorage", // "cookie" (default), "sessionStorage" or "localStorage"
    });
  }
  return authClientInstance;
};

What it's for

01

Sign-in that works the same everywhere

One AuthClient configuration covers email/password, session refresh and logout. Wire it into a React or Next.js app once, and every authenticated call through AuthenticatedBaseService carries a valid token.

02

Multiple sessions in the same browser

sessionStorage or localStorage mode isolates a session per tab, which matters if your app, or your team, moves between projects or environments without wanting one login to bleed into another.

03

Data calls stay on the REST API

The SDK doesn't wrap your entities in a query builder. You call the same REST endpoints documented in the API reference, through a service class that handles the auth header and token refresh for you.

Frequently Asked Questions

Does the SDK generate a typed client for my entities?

Not today. The SDK covers sign-in and sessions — AuthClient, AuthProvider, useAuth and AuthenticatedBaseService. Data calls go through the REST API directly. A typed data client is on the roadmap, with no date set yet.

Is there realtime data in the SDK?

Realtime subscriptions are planned. Today the SDK handles sign-in and sessions, and your app reads and writes data through the REST API.

What does authPrefix do on AuthProvider?

It tells the provider which route prefix your login pages live under, so it matches the API's expectations for where to send an unauthenticated user. It must match your app's actual login route, for example /auth for pages under /auth/login.

Is a Flutter SDK available?

A Flutter SDK is planned, alongside a typed data client. Today Flutter apps use the REST API directly, including sign-in with Apple and Google.

Still have questions?

Get in Touch

More in the same project

Every feature reads from the same data model, so each one you add works with the rest.