Skip to main content
npayload is launching soon.
npayloadDocs
SDKs

SDKs

Official npayload SDKs for Node.js, React, and browser environments

npayload provides official TypeScript SDKs for server-side, client-side, and React applications. All SDKs include full type safety and OAuth 2.0 + DPoP authentication.

Available SDKs

SDKPackageUse case
Node.js@npayload/nodeServer-side: publish messages, manage channels, verify webhooks
React@npayload/reactReact hooks: useChannels, useMessages, usePublish, real-time
Browser@npayload/jsClient-side: real-time subscriptions, browser crypto
ASP@devopscrowdca/asp-jsAgent sessions, trust scoring, negotiation

Installation

# Server-side
npm install @npayload/node

# React hooks
npm install @npayload/react

# Browser client
npm install @npayload/js

Quick example

import { NPayloadAuth, NPayloadClient } from '@npayload/node';

const auth = new NPayloadAuth({
  clientId: process.env.NPAYLOAD_CLIENT_ID!,
  hmacSecret: process.env.NPAYLOAD_HMAC_SECRET!,
});

const npayload = new NPayloadClient({ auth });

// Publish a message
await npayload.messages.publish({
  channel: 'events',
  payload: { type: 'user.created', userId: 'user_123' },
});

Error handling

All SDKs throw typed errors:

import { NPayloadError, RateLimitError, AuthenticationError } from '@npayload/node';

try {
  await npayload.channels.get('invalid_id');
} catch (error) {
  if (error instanceof RateLimitError) {
    // Wait and retry
  } else if (error instanceof AuthenticationError) {
    // Re-authenticate
  } else if (error instanceof NPayloadError) {
    console.error('API Error:', error.message);
  }
}

REST API

If you prefer direct HTTP integration, see the API reference for all endpoints.

Was this page helpful?

On this page