paykit
v0.1 beta

Plugins

Extend PayKit with plugins that add endpoints and functionality.

Plugins extend PayKit by adding endpoints to its HTTP router. They're optional. Core PayKit works without any plugins.

Using a plugin

Install the plugin package, then pass it to createPayKit via the plugins array.

paykit.ts
import { dash } from "@paykitjs/dash";

export const paykit = createPayKit({
  // ...
  plugins: [dash()],
});

Each plugin mounts its own endpoints under the PayKit base path automatically. No manual route wiring needed.

Dashboard plugin

@paykitjs/dash adds an embedded billing dashboard your users can access directly from your app. It shows subscriptions, invoices, and lets customers manage their payment methods.

pnpm add @paykitjs/dash
bun add @paykitjs/dash
npm install @paykitjs/dash

Pass an authorize function to control who can access it. Without authorize, the dashboard is open to any authenticated request.

paykit.ts
import { dash } from "@paykitjs/dash";

export const paykit = createPayKit({
  // ...
  plugins: [
    dash({
      authorize: async (request) => {
        const session = await auth.api.getSession({
          headers: request.headers,
        });
        if (!session) throw new Error("Not authenticated");
      },
    }),
  ],
});

Throwing inside authorize blocks access. Returning without throwing grants it.

Plugin interface

A plugin is a plain object with an id and an optional endpoints map. PayKit mounts each endpoint under the configured base path.

type Plugin = {
  id: string;
  endpoints?: Record<string, EndpointHandler>;
};

The id must be unique across all plugins. PayKit uses it to namespace routes and avoid collisions.