mybasev1.0.21

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/sdk

Configure 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:write

Put 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

Package entry points

Import only the helpers your app needs:

ImportUse
@mybase-dev/sdk/analyticsRecord page views, custom events, and errors
@mybase-dev/sdk/cronVerify calls, handle jobs, and schedule one-off tasks
@mybase-dev/sdk/cacheRead and write the project's cache over HTTP
@mybase-dev/sdk/ratelimitCheck rate limits
@mybase-dev/sdk/queueSend, receive, and consume queue messages
@mybase-dev/sdk/searchSearch the web and read pages, plus tools for LLM agents
@mybase-dev/sdk/vectorVector, full-text, and hybrid search over documents, plus a retrieval tool for agents
@mybase-dev/sdk/better-authBetter Auth on mybase: database URL, session storage, audit plugin, captcha
@mybase-dev/sdk/captchaSolve captcha challenges in the browser and verify tokens on the server
@mybase-dev/sdk/realtimeWebSocket channels: connect from browsers, publish from servers, presence, webhooks
@mybase-dev/sdk/sandboxCreate agent workspaces, run code, connect Chromium, transfer files, and retain artifacts
@mybase-dev/sdk/configDeclare jobs, rate limit rules, queues, and vector indexes for mybase cron sync / ratelimit sync / queue sync / vector sync

On this page