@edge-base/admin
v0.2.6
Published
EdgeBase admin SDK — server-side client for user management, database admin, and analytics
Readme
@edge-base/admin is the trusted server-side SDK for EdgeBase.
Use it when you need:
- Service Key authenticated access
- server-side database operations that bypass access rules
- admin user management
- raw SQL
- push and analytics from secure environments
- server-to-server function calls
If code runs in a browser, use @edge-base/web instead. If code runs on the server but should act as the current signed-in user through cookies, use @edge-base/ssr.
EdgeBase is the open-source edge-native BaaS that runs on Edge, Docker, and Node.js.
This package is one part of the wider EdgeBase platform. For the full platform, CLI, Admin Dashboard, server runtime, docs, and all public SDKs, see the main repository: edge-base/edgebase.
Beta: the package is already usable, but some APIs may still evolve before general availability.
Documentation Map
- Database Admin SDK Server-side database access with a Service Key
- Admin Users Create, update, list, revoke, and manage users
- Push Admin SDK Send push notifications from secure environments
- Analytics Admin SDK Query request analytics and track server-side events
- Admin SDK Reference Public admin SDK surface by category
For AI Coding Assistants
This package ships with an llms.txt file for AI-assisted server SDK usage.
You can find it:
- after install:
node_modules/@edge-base/admin/llms.txt - in the repository: llms.txt
Use it when you want an agent to:
- keep Service Key logic on the server
- choose between
web,ssr, andadmin - use the correct
db(namespace, id?)andsql(...)signatures - avoid shipping privileged SDK code to the browser
Installation
npm install @edge-base/adminQuick Start
import { createAdminClient } from '@edge-base/admin';
const admin = createAdminClient(process.env.EDGEBASE_URL!, {
serviceKey: process.env.EDGEBASE_SERVICE_KEY,
});
const { items: posts } = await admin
.db('app')
.table('posts')
.orderBy('createdAt', 'desc')
.limit(20)
.getList();
console.log(posts);Inside EdgeBase App Functions, you can also rely on environment detection:
import { createAdminClient } from '@edge-base/admin';
const admin = createAdminClient();Core API
Once you create an admin client, these are the main surfaces you will use:
admin.db(namespace, id?)Server-side database accessadmin.authAdmin user managementadmin.sql(...)Raw SQL executionadmin.storageServer-side storage accessadmin.functionsCall app functions from trusted codeadmin.pushSend push notificationsadmin.analyticsQuery analytics and track server-side eventsadmin.kv(namespace),admin.d1(database),admin.vector(index)Access platform resources from trusted code
Database Access
type Post = {
id: string;
title: string;
status: 'draft' | 'published';
};
const posts = admin.db('app').table<Post>('posts');
const result = await posts
.where('status', '==', 'published')
.orderBy('title', 'asc')
.limit(50)
.getList();For instance databases, pass the instance id positionally:
admin.db('workspace', 'ws-123');
admin.db('user', 'user-123');Read more: Database Admin SDK
Admin Auth
const created = await admin.auth.createUser({
email: '[email protected]',
password: 'secure-pass-123',
displayName: 'June',
});
await admin.auth.setCustomClaims(created.id, {
role: 'moderator',
});
const users = await admin.auth.listUsers({ limit: 20 });
console.log(users.users);Read more: Admin Users
Raw SQL
sql() supports two forms:
const health = await admin.sql('select 1 as ok');
const docs = await admin.sql(
'workspace',
'ws-123',
'select * from documents where status = ?',
['published'],
);Push And Analytics
await admin.push.send('user-123', {
title: 'Deployment finished',
body: 'Your content is live.',
});
const overview = await admin.analytics.overview({ range: '7d' });
console.log(overview.summary.totalRequests);Read more:
Choose The Right Package
| Package | Use it for |
| --- | --- |
| @edge-base/web | Browser and untrusted client code |
| @edge-base/ssr | Server-side code acting as the current cookie-authenticated user |
| @edge-base/admin | Trusted server-side code with Service Key access |
License
MIT
