logic-sdk weekly downloads statistics
Queries, mutations, actions and events for TypeScript apps. Transactions, after-commit events and scopes, on any runtime.
logic-sdk has 2,061 recorded weekly downloads on npm, a change of +10.7% over the past 7 days, ranking #1869 of 3,247 tracked listings.
About logic-sdk
Logic SDK
Write your logic once. Run it anywhere. One function for your API, your AI agent and your jobs, on Node, Cloudflare Workers or Vercel. Transactions, events after commit, retries and policies are built in. Your database stays yours.
Install
npm install logic-sdk zod
Requires Node.js 24+ (also runs on Bun and Cloudflare Workers). Mutations need Postgres or SQLite, through Drizzle or any ORM that runs SQL in a transaction. Zod is optional: any Standard Schema library works, such as Valibot or ArkType.
Quick start
A mutation that emits an event, and a listener that reacts to it:
import { init } from "logic-sdk";
import { z } from "zod";
type Scope = { user: { id: string } | null };
export const { mutation, event, listener, createRegistry } = init<{ scope: Scope }>();
export const orderPlaced = event({ payload: z.object({ orderId: z.string() }) });
export const placeOrder = mutation({
input: z.object({ items: z.array(Item).min(1) }),
authorize: (scope) => scope.user !== null,
async handler(ctx, { items }) {
const [order] = await ctx.db.insert(orders).values({ items }).returning();
ctx.emit(orderPlaced, { orderId: order.id }); // delivered after the commit
return order;
},
});
export const sendReceipt = listener({
event: () => orderPlaced,
attempts: 3, // tried again if the mailer fails
async handler(ctx, { orderId }) {
await ctx.services.mailer.send({ orderId });
},
});
Register the module, then run the function from a route, an AI agent, a job, a script or a test:
import { drizzleAdapter } from "logic-sdk/drizzle/pg";
const registry = createRegistry({
modules: { orders },
database: { adapter: drizzleAdapter(db) },
services: { mailer },
});
const caller = registry.as({ user: { id: "ana" } });
await caller.run(orders.placeOrder, { items });
Change the entry file to change platforms. Your modules stay the same: see one app on Node, Workers and Next.js.
What you get
- One transaction across modules. A failure anywhere rolls back everything.
- Events after commit. Listeners run as jobs, with retries, only after the data is saved.
- Policies on every call.
authorizeruns for a route, an AI agent, a job and a nested call alike. - Typed errors. Declare each error once. Callers switch on its code.
- Any schema library. Zod, Valibot, ArkType or any other Standard Schema library types the inputs, outputs and events.
- Tests without mocks. Each test runs on a real database, in a transaction that rolls back.
- Zero runtime dependencies. The one dependency,
@standard-schema/spec, ships types only. The AI, oRPC and Drizzle integrations use the copies you already have, as optional peers. - No magic. No decorators, classes, codegen or build step.
Adapters
| Import | For |
|---|---|
logic-sdk/drizzle/pg, logic-sdk/drizzle/sqlite | The database, and jobs in a table |
logic-sdk/postgres, logic-sdk/sqlite | Jobs in a table, with any ORM |
logic-sdk/cloudflare | Cloudflare Queues and Cron Triggers |
logic-sdk/node | work(registry): jobs and crons in a long-running process |
logic-sdk/ai | Your functions as AI SDK tools |
logic-sdk/orpc | Your functions as oRPC procedures |
logic-sdk/fetch | An error as an HTTP response |
logic-sdk/testing | Tests that roll back, with a fixed clock |
CLI
npx logic-sdk list # every function, its kind and policy
npx logic-sdk show orders.place # what one function takes, runs, emits and fails with
npx logic-sdk graph # which module runs what, and who listens to each event
Skill for coding agents
The package ships a skill for coding agents: node_modules/logic-sdk/skills/logic-sdk/SKILL.md. It tells the agent where each piece goes.
Docs
logic-sdk.dev has the quickstart, the concepts, the guides and the reference. Two example apps are in examples.
License
MIT
Description from the npm listing.
- actions
- agents
- ai-agents
- ai-sdk
- business-logic
- cloudflare-workers
- drizzle
- events
- mutations
- queries
- tools
- transactions
- typescript
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (121)Similar npm AI SDKs plugins
All 20 logic-sdk alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/logic-sdk. First seen Dec 2, 2026; last successful collection Dec 6, 2026. See the methodology.