Getting started
The Jet Admin SDK connects your application to resources configured in a Jet Admin project. It includes TypeScript definitions and asynchronous methods that return promises. Agent streaming uses an async generator.
Before you start
You need:
A Jet Admin project identifier and environment name.
The resource and collection identifiers used by that project's API, or a workflow or agent UID. Use API identifiers rather than display labels.
A user account permitted to access the data, with email/password login enabled for your project if you follow this example.
A browser application with a bundler and access to
localStorage.
The examples below use placeholder identifiers and sample fields. Replace them with identifiers and fields from your project.
Install
The package name in this repository is @jet-admin/jet-sdk:
npm install @jet-admin/jet-sdkUse your team's configured package registry and credentials. Package publication and registry access were not verified as part of this source review. If installation reports a missing or private package, ask the SDK maintainer for registry access or a supported package artifact.
Read your first records
Run this from a browser application. Pass credentials from your login form; do not hard-code a real password.
import { Jet, JetRequestError } from '@jet-admin/jet-sdk';
const jet = new Jet({
project: 'YOUR_PROJECT',
environment: 'prod',
});
async function loadCustomers(email: string, password: string) {
try {
await jet.auth.loginViaEmailPassword(email, password);
const page = await jet.collection('YOUR_RESOURCE', 'customers').list({
pagination: { page: 1, perPage: 25 },
});
return page.results.map(record => record.data);
} catch (error) {
if (error instanceof JetRequestError) {
console.error(error.message, error.fieldErrors);
}
throw error;
}
}Each record is a CollectionRecord. Access your fields through record.data, for example record.data.name. Collection records are not generic typed models; field values have type unknown until your application validates or narrows them.
Choose your next step
Runtime compatibility
Initialize the SDK on the client in applications that render on a server. new Jet(...) reads localStorage immediately, even when an API token is supplied. Storage uploads also reference File, Blob, and FormData. Agent streaming requires fetch, readable streams, and TextDecoder.
The repository does not declare a supported Node.js version or provide a server storage adapter. Do not use shared global authentication storage for multiple users on a server. See service requests and server use.
Was this helpful?