Skip to Content
Install package

Install the Nibgate package

Use the package inside the app that owns the paid content. The package is the unlock and event bridge, not just a metrics helper.

Nibgate is framework-agnostic. Install one package, then use the browser entrypoint for content/event reporting and the server entrypoint for real access enforcement.

Agents can read the compact integration guide at https://nibgate.xyz/skill.md . If you are using an AI coding agent, give it that URL or the package file node_modules/@nibgate/sdk/SKILL.md before it edits checkout, route protection, or widget code.

Install

npm install @nibgate/sdk
import { createGate } from '@nibgate/sdk' import { createCircleGatewayServer } from '@nibgate/sdk/server'

Do not put backend secrets, private signing keys, or privileged payment credentials in browser code. Server-only event submission should happen from your backend or trusted server route.

What the package owns

  • Gating protected resources.
  • Defining price, currency, content type, and receiver metadata.
  • Starting unlock flows.
  • Reporting unlock completion or failure.
  • Sending content metadata to the hub.
  • Reporting receipts for dashboard analytics.

Framework support

The core package is not tied to one framework.

  • Next.js: route handlers, API routes, SSR pages, DB-backed blogs, and MDX flows.
  • React: browser events and unlock UI, with a separate protected backend route.
  • Express and NestJS: middleware, guards, or controller-level protection.
  • Remix, SvelteKit, Astro SSR, and serverless/edge routes: check access before returning the payload.
  • WordPress, Ghost, and traditional CMS setups: plugin, theme helper, or middleware when the platform allows server-side extension.
  • Plain HTML/static sites: widget and public metadata work, but private payloads need a protected API, edge function, or signed URL.

Rule: if the framework can run server logic before returning content, Nibgate can enforce real access.

Hardcoded content

Hardcoded content can be gated when it stays server-only until access is allowed. MDX, Markdown, constants, JSON files, and local media metadata are fine if the full paid payload is loaded by a route handler, API route, server component, middleware, guard, private file reader, or signed URL endpoint after Nibgate verifies access.

Do not render paid text into public HTML and hide it with CSS or client state. Do not bundle the paid body into client JavaScript.

Admin UI settings

If your site has a blog editor or admin page, save Nibgate settings beside each content record. The package exposes canonical field metadata so the same settings can be rendered in Next, Express, CMS schemas, or custom dashboards:

import { NIBGATE_CONTENT_SETTING_FIELDS, createNibgateContentSettings } from '@nibgate/sdk' const defaults = createNibgateContentSettings({ recipient: creatorDefaultWallet, })

Typical saved fields are content type, price, currency, recipient wallet, human access, agent access, unlock mode, license terms, and whether the content should appear in Nibgate discovery.

Configure the site

Keep the siteId, public origin, and API base in environment variables.

Define content

Every gated resource should have a stable external id, content type, title, URL/path, price, currency, human/agent access policy, and one_time unlock policy.

Gate access

Protect the route or resource before serving the paid content.

Emit events

Send content metadata reports, impressions, unlock starts, unlock completions, and receipts to the Nibgate backend.

Browser versus server

The browser can display unlock UI and page activity. The server should own anything that proves payment, signs trusted events, or talks with privileged credentials.

Browser Gateway checkout must be paired with a server route running Circle Gateway mode. Use createCircleGatewayServer(...), or manually set paymentMode: 'circle-gateway' and network: 'eip155:5042002', so the route returns Circle’s real PAYMENT-REQUIRED batching challenge.

Last updated on