Skip to main content

Admin SDK

Admin SDKs run on your backend server and authenticate with a Service Key. They bypass access rules and unlock server-only features like Admin Auth, Raw SQL, Broadcast, Functions, Analytics, and Cloudflare native resources.

Admin SDKs are available in 12 languages: JavaScript, Dart, Kotlin, Java, Scala, Python, Go, PHP, Rust, C#, Ruby, and Elixir.

For the latest cross-runtime certification status across dev, docker, and deployed, see SDK Verification Matrix.

At a Glance​

Client SDKAdmin SDK
Runs onBrowser, Mobile, Game EngineBackend server, Cloud function, CLI
Auth methodUser token (JWT)Service Key
Access RulesAppliedBypassed
User auth (signUp/signIn)✅—
Admin auth (createUser/deleteUser)—✅
Database subscriptions✅—
Database broadcast (server send only)—✅
Raw SQL—✅
Push send / logs—✅
Functions / webhooks invoke—✅
Analytics / event queries—✅
KV / D1 / Vectorize—✅
warning

Never expose the Service Key in client-side code. It has full admin access to your backend, including user management and raw SQL execution.

For installation instructions, see SDK Overview — select the "Admin SDK" tab for each language.

Admin SDKs do not expose client WebSocket subscriptions. They can, however, publish server-side database broadcasts into subscription channels with Service Key authority.


Admin-Only Features​

These features require a Service Key and are only available in admin mode.

Admin Auth​

Manage users programmatically — create, update, delete, set custom claims.

const user = await admin.auth.createUser({
email: 'admin@example.com',
password: 'securePassword',
displayName: 'Admin',
role: 'admin',
});

await admin.auth.setCustomClaims('user-id', { plan: 'pro' });
await admin.auth.revokeAllSessions('user-id');

Raw SQL​

Execute raw SQL queries against your database.

const rows = await admin.sql('posts',
'SELECT authorId, COUNT(*) as cnt FROM posts GROUP BY authorId ORDER BY cnt DESC LIMIT ?',
[10]
);

Server-Side Broadcast​

Send broadcast messages from your server to all connected clients.

await admin.broadcast('notifications', 'alert', {
message: 'System maintenance in 5 minutes',
});

Cloudflare Native Resources (KV / D1 / Vectorize)​

Access user-defined Cloudflare KV, D1 databases, and Vectorize indexes directly from your server code. Resources must be declared in edgebase.config.ts — only allowlisted bindings are accessible.

// KV — cache, session store, feature flags
await admin.kv('cache').set('key', 'value', { ttl: 300 });
const val = await admin.kv('cache').get('key');
await admin.kv('cache').delete('key');
const list = await admin.kv('cache').list({ prefix: 'user:' });

// D1 — analytics, logs, relational queries
const rows = await admin.d1('analytics').exec(
'SELECT * FROM events WHERE type = ?',
['pageview']
);

// Vectorize — semantic search, RAG, recommendations
await admin.vector('embeddings').upsert([
{ id: 'doc-1', values: [0.1, 0.2, ...], metadata: { title: 'Hello' } },
]);
const results = await admin.vector('embeddings').search(
[0.1, 0.2, ...],
{ topK: 10, filter: { type: 'article' } }
);
Local Development

KV and D1 work in local and Docker environments via Miniflare emulation. Cloudflare does not provide a local Vectorize simulation; Wrangler can use remote bindings, while EdgeBase falls back to stub responses when a Vectorize binding is unavailable.


Choosing the Right SDK​

Web App (React, Vue, Svelte)​

Use the JavaScript SDK in client mode for the frontend. If you need server-side rendering (SSR) or API routes, use server mode in your backend.

Mobile App (Flutter)​

Use the Dart SDK in client mode. For background processing or admin tasks, use server mode in your Dart backend.

Mobile App (React Native)​

Use the React Native SDK in client mode.

Mobile App (iOS native)​

Use the Swift SDK in client mode.

Mobile App (Android native)​

Use the Kotlin SDK in client mode.

Game (Unity)​

Use the C# SDK — client mode for Unity, admin mode for ASP.NET Core / .NET backend servers.

Game (Unreal Engine)​

Use the C++ SDK (alpha) — client only. For admin operations, use a separate backend.

Backend API / Microservice​

Use Go, PHP, Rust, Ruby, Scala, or Elixir SDK. These are server-only and authenticate with a Service Key.

Scripts / Automation / ML​

Use the Python, Ruby, or Elixir SDK with a service key. These are all strong fits for scripts, automation, and data tasks.


Next Steps​