Skip to content

Getting started

This guide walks through wiring the Eventista SDKs into a fresh consumer app — web, Node, or React Native.

The packages live in a private AWS CodeArtifact repository. Each developer machine and CI environment must obtain a token before bun install can resolve @eventista/*.

Terminal window
aws codeartifact login --tool npm \
--domain eventista-sdks --domain-owner 533267118170 \
--repository eventista-sdks --region ap-southeast-1

The token is valid for 12 hours. Re-run the command when installs start failing with 401.

Pick the packages you need. @eventista/sdk-core is a transitive dependency of every other SDK — you only need to install it explicitly if you use it directly.

Terminal window
bun add @eventista/sdk-auth @eventista/sdk-api-client @eventista/sdk-core
  1. Pick an environment. AuthClient ships with AuthEnvironment.Production and AuthEnvironment.Development — these resolve the right backend URLs for you.

  2. Provide a storage adapter. Tokens are persisted via a TokenStorageAdapter you supply. The default in-memory adapter is fine for SSR and tests, but every interactive app should wire its own.

  3. Subscribe to token changes. onTokensChanged fires whenever the SDK persists a new pair, including on first login and refresh. Use this to mirror state into your auth store.

lib/auth.ts
import { AuthClient, AuthEnvironment } from "@eventista/sdk-auth";
export const auth = new AuthClient({
environment: AuthEnvironment.Production,
onTokensChanged: (tokens) => {
if (tokens === null) {
// signed out
return;
}
// tokens.accessToken, tokens.refreshToken, tokens.expiresAt
},
});
const result = await auth.login({ email: "a@b.test", password: "secret" });
if (result.isErr) {
if (result.code === "AUTH_INVALID_CREDENTIALS") {
showError("Wrong email or password");
return;
}
reportToSentry(result.code, result.errorCode, result.err);
return;
}
setUser(result.data.user);

AuthClient methods never throw on auth failure — branch on result.isErr first, then on the typed result.code.