Pick your app

The examples below will be updated with your app ID.

Introduction

Connecting to Superlayer

Superlayer maintains its own SDK source under @superlayer/*. The packages default to https://api.interfacedb.com and wss://api.interfacedb.com/runtime/session; hosted apps need no URL configuration. Find packages in the Superlayer npm organisation.

#React

npm install @superlayer/react
import { init, i, id } from '@superlayer/react';
const schema = i.schema({
entities: {
notes: i.entity({ title: i.string(), done: i.boolean() }),
},
});
export const db = init({
appId: process.env.NEXT_PUBLIC_SUPERLAYER_APP_ID!,
schema,
});
// In a React component:
// const { data, isLoading, error } = db.useQuery({ notes: {} });
// await db.transact(db.tx.notes[id()].update({ title: 'First idea', done: false }));

React Native, Vue, Svelte and Solid use the corresponding @superlayer/react-native, @superlayer/vue, @superlayer/svelte and @superlayer/solidjs packages. Next.js helpers are available from @superlayer/react/nextjs.

#Server/admin

npm install @superlayer/admin
import { init, id } from '@superlayer/admin';
const db = init({
appId: process.env.SUPERLAYER_APP_ID!,
adminToken: process.env.SUPERLAYER_ADMIN_TOKEN!,
});
await db.transact(db.tx.notes[id()].update({ title: 'Server-created note' }));
const data = await db.query({ notes: {} });

The app ID is public. Keep the admin token in trusted server code. Admin requests bypass app permission rules but share workspace usage limits.

#CLI

npx @superlayer/cli login
npx @superlayer/cli init --app YOUR_APP_ID
npx @superlayer/cli push --app YOUR_APP_ID

An operator must approve the login email. The installed executable is superlayer. Existing instant.schema.ts, instant.perms.ts, instant.config.ts and INSTANT_CLI_* overrides remain supported.

The app generator is npx @superlayer/create-app. Copy the command for your existing app from the dashboard; generated JavaScript apps import Superlayer packages.

#Local development and self-hosting

Only custom deployments need endpoint overrides:

const db = init({
appId: 'YOUR_APP_ID',
apiURI: 'http://localhost:18888',
websocketURI: 'ws://localhost:18888/runtime/session',
});

The admin SDK needs only apiURI. For the CLI:

INSTANT_CLI_API_URI=http://localhost:18888 \
INSTANT_CLI_DASH_URI=http://localhost:3140 \
npx @superlayer/cli login

#Migrating from Instant packages

Replace SDK dependencies and imports from @instantdb/* to @superlayer/*. Remove URL overrides when connecting to hosted Superlayer; retain custom deployment overrides. Query, transaction, hook and schema APIs are unchanged. Python remains the upstream package and requires an explicit Superlayer endpoint.

If you are an LLM trying to learn how to develop with Superlayer, here are all of the links to the docs:

Getting started w/ ReactGetting started w/ React NativeGetting started w/ Vanilla JSGetting started w/ SolidJSGetting started w/ SvelteGetting started w/ VueGetting started w/ TanStack StartGetting started w/ PythonCreate Superlayer AppConnecting to SuperlayerRecommended WorkflowUsing LLMsInitModeling dataWriting dataReading dataInfinite QueriesSuperlayer on the backendPatternsAuthMagic codesGuest AuthGoogle OAuthSign In with AppleGitHub OAuthLinkedIn OAuthClerkFirebase AuthPermissionsRate LimitsManaging usersPresence, Cursors, and ActivitySuperlayer CLIDevtoolPlatform APIExplorer ComponentCustom emailsApp teamsStorageStreamsWebhooksBackupsStripe PaymentsAdmin HTTP API(Experimental) Next.js SSROverviewVPSAWSMigrate from Superlayer Cloud
Connecting to Superlayer