Getting started
`@mybase-dev/sdk` helps your app send analytics, receive signed cron calls, schedule one-off tasks, use its cache, check rate limits, and send and receive queue messages through mybase.
@mybase-dev/sdk helps your app send analytics, receive signed cron calls, schedule one-off tasks, use its cache, check rate limits, and send and receive queue messages through mybase. It has no runtime dependencies and uses Web Crypto; run it in Node 20+, Bun, Deno, or a compatible edge runtime.
Install
npm install @mybase-dev/sdk
# or: bun add @mybase-dev/sdkConfigure your app
Most helpers authenticate with a mybase API key (mb_…). Each key has permissions per service (queue:write, ratelimit:write, cache:write, cron:write, … or admin) and can be limited to some projects, so one key can cover everything an app uses. Create one in the dashboard (Settings → API keys) or with the CLI:
mybase token create shop-app --project shop --perm queue:write,ratelimit:write,cache:write,cron:writePut it in your app's server-side environment as MYBASE_API_KEY. Never expose it to browser code; analytics uses its own public write key for that.
For cron, find your project's cron secret on its Cron page or run mybase cron secret <project>. Put it in your app's server-side environment as MYBASE_CRON_SECRET. Never expose it to browser code.
Your app needs an HTTP endpoint reachable from the mybase server. mybase sends POST requests to it; the SDK verifies signatures before invoking your handlers.
Choose a guide
- Handle cron calls to receive scheduled jobs.
- Define jobs in code to sync schedules with the CLI.
- Schedule one-off tasks from your app's server-side code.
- Track page views, events, and errors with analytics.
- Use the cache over TCP or HTTP.
- Check rate limits shared by every instance of your app.
- Use queues to hand work off to background workers.
- Search the web and read pages from your app's AI agent.
- Search your documents by meaning, keywords, or both.
- Sign users in with Better Auth, backed by mybase.
- Check forms for bots with the self-hosted captcha.
- Push live updates to browsers over WebSocket channels, even from a serverless app.
- Run agent code and Chromium in temporary isolated workspaces, with execution results and private artifacts.
Package entry points
Import only the helpers your app needs:
| Import | Use |
|---|---|
@mybase-dev/sdk/analytics | Record page views, custom events, and errors |
@mybase-dev/sdk/cron | Verify calls, handle jobs, and schedule one-off tasks |
@mybase-dev/sdk/cache | Read and write the project's cache over HTTP |
@mybase-dev/sdk/ratelimit | Check rate limits |
@mybase-dev/sdk/queue | Send, receive, and consume queue messages |
@mybase-dev/sdk/search | Search the web and read pages, plus tools for LLM agents |
@mybase-dev/sdk/vector | Vector, full-text, and hybrid search over documents, plus a retrieval tool for agents |
@mybase-dev/sdk/better-auth | Better Auth on mybase: database URL, session storage, audit plugin, captcha |
@mybase-dev/sdk/captcha | Solve captcha challenges in the browser and verify tokens on the server |
@mybase-dev/sdk/realtime | WebSocket channels: connect from browsers, publish from servers, presence, webhooks |
@mybase-dev/sdk/sandbox | Create agent workspaces, run code, connect Chromium, transfer files, and retain artifacts |
@mybase-dev/sdk/config | Declare jobs, rate limit rules, queues, and vector indexes for mybase cron sync / ratelimit sync / queue sync / vector sync |