npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codebolt/miniapp

v0.1.2

Published

`@codebolt/miniapp` is the authoring SDK and Nitro build adapter for CodeBolt MiniApps.

Readme

@codebolt/miniapp

@codebolt/miniapp is the authoring SDK and Nitro build adapter for CodeBolt MiniApps.

The package has three library entry points plus a command-line entry:

@codebolt/miniapp        # MiniApp author/runtime API
@codebolt/miniapp/nitro  # Nitro build adapter
@codebolt/miniapp/bundle # .miniapp archive builder and verifier
codebolt-miniapp-bundle  # pack, inspect, and verify commands

Use the root export from MiniApp code, the ./nitro export only from nitro.config.ts, and the ./bundle export only from Node-side build tooling.

Root Export

import {
  defineTool,
  defineCollection,
  useMiniApp,
} from "@codebolt/miniapp";

The root export contains the MiniApp definition helpers and runtime context API.

defineTool()

Declares a CodeBolt tool. It adds kind: "tool" to the object and preserves the metadata, JSON schemas, and handler.

import { defineTool } from "@codebolt/miniapp";

export default defineTool({
  name: "add-lead",
  description: "Store a discovered lead.",
  inputSchema: {
    type: "object",
    additionalProperties: false,
    required: ["id", "name", "company"],
    properties: {
      id: { type: "string", minLength: 1 },
      name: { type: "string", minLength: 1 },
      company: { type: "string", minLength: 1 },
      email: { type: "string" },
    },
  },
  async handler(context, input) {
    return context.db.set("leads", input.id, input);
  },
});

defineTool() does not register routes or scan files by itself. Tool discovery is done by codeboltMiniApp() from @codebolt/miniapp/nitro.

defineCollection()

Declares a collection schema for manifest/catalog metadata.

import { defineCollection } from "@codebolt/miniapp";

export default defineCollection({
  name: "leads",
  schema: {
    type: "object",
    required: ["id", "name", "company"],
    properties: {
      id: { type: "string" },
      name: { type: "string" },
      company: { type: "string" },
      email: { type: "string" },
    },
  },
});

useMiniApp()

Returns the runtime context for API routes and tool handlers.

import { defineHandler } from "nitro/h3";
import { useMiniApp } from "@codebolt/miniapp";

export default defineHandler((event) => {
  return useMiniApp(event).db.list("leads");
});

The context currently exposes:

context.miniAppId;
context.installId;
context.workspaceId;
context.principal;
context.db;
context.blob;
context.codebolt.tasks;

For local CodeBolt hosting, useMiniApp() reads the worker-injected runtime bridge. For remote Node or Cloudflare output, it reads the execution token from the request and calls the configured CodeBolt Cloud capability endpoint.

Pass the Nitro event in server routes:

export default defineHandler((event) => useMiniApp(event).db.list("leads"));

Remote serverless requests need the event because the execution token lives in the current request headers. Local host mode can work without an event because the host injects a runtime bridge into the MiniApp worker. Tool handlers usually do not call useMiniApp() directly because the CodeBolt tool route creates the context and passes it to the tool handler.

Nitro Export

import { codeboltMiniApp, resolveTarget } from "@codebolt/miniapp/nitro";

The Nitro export contains build-time integration code. Keep it out of ordinary tool and route files.

resolveTarget()

Returns the Nitro output config for the selected MiniApp target.

resolveTarget();          // uses process.env.MINIAPP_TARGET
resolveTarget("local");   // standard preset, .output
resolveTarget("node");    // node-server preset, .output-node
resolveTarget("cloudflare"); // cloudflare-module preset, .output-cloudflare

The local target uses Nitro's standard preset with serveStatic: false, because the CodeBolt host serves static assets itself.

codeboltMiniApp()

Registers the CodeBolt MiniApp build behavior as a Nitro module.

import { defineConfig } from "nitro";
import { codeboltMiniApp, resolveTarget } from "@codebolt/miniapp/nitro";

export default defineConfig({
  ...resolveTarget(),
  compatibilityDate: "2026-07-24",
  serverDir: "server",
  modules: [
    codeboltMiniApp({
      id: "leads",
      title: "Lead Depository",
      version: "0.1.0",
      route: "/",
    }),
  ],
});

During nitro build, codeboltMiniApp():

  • scans server/tools and server/collections
  • loads default-exported MiniApp definitions
  • creates virtual modules for tool lookup and validation
  • registers POST /__codebolt/tools/:name
  • emits .output/codebolt/miniapp.manifest.json

Input validators are compiled during the build and emitted as standalone functions. Do not move Ajv compilation back into the request path; Cloudflare Workers reject runtime string-based code generation.

Without codeboltMiniApp(), Nitro can still bundle imports from @codebolt/miniapp, but CodeBolt tool files will not be discovered, tool routes will not be registered, and no MiniApp manifest will be generated.

Expected File Layout

server/
  api/
    leads.get.ts
  tools/
    add-lead.ts
  collections/
    leads.ts
public/
  index.html
nitro.config.ts
package.json

Nitro owns normal API route handling under server/api. CodeBolt-specific definition scanning is limited to server/tools, server/collections, and the single UI entry declared in codeboltMiniApp({ title, route }).

Package Boundary

This package intentionally keeps two concepts separate:

  • Root export: stable MiniApp authoring/runtime API.
  • ./nitro export: Nitro-specific build-time adapter.
  • ./bundle export: Node-side packaging of cloudflare-module output into the generic MiniApp Server ABI.

Cloud Bundle Build

Build the normal Cloudflare module output, then package it without deploying a separate Worker:

$env:MINIAPP_TARGET='cloudflare'
npm run build
npx codebolt-miniapp-bundle pack .output-cloudflare --output dist/my-app.miniapp

The archive contains Nitro's complete module graph, public assets, CodeBolt manifest metadata, checksums, and a generated codebolt.fetch.v1 adapter. It does not contain a Durable Object class; the shared MiniApp Server injects that lifecycle at install time.

That allows app code to stay framework-neutral while keeping the current Nitro integration explicit and easy to customize in nitro.config.ts.

Related Docs

  • ../../packages/host/README.md: local host and worker runtime.
  • ../../MINIAPP_PUBLISHING_AND_USAGE.md: local usage, cloud publishing, portal install flow, and agent tool exposure.
  • ../../examples/leads/README.md: lead depository example.
  • ../../examples/onboarding/README.md: onboarding example.
  • ../../skills/create-miniapp/SKILL.md: agent instructions for authoring new MiniApps.