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
| SDK | Package | Use case |
|---|---|---|
| Node.js | @npayload/node | Server-side: publish messages, manage channels, verify webhooks |
| React | @npayload/react | React hooks: useChannels, useMessages, usePublish, real-time |
| Browser | @npayload/js | Client-side: real-time subscriptions, browser crypto |
| ASP | @devopscrowdca/asp-js | Agent sessions, trust scoring, negotiation |
Node.js
Full-featured server SDK with OAuth + DPoP, channels, messages, subscriptions, DLQ, and webhook verification
React
React hooks for channels, messages, real-time subscriptions, and publishing with optimistic updates
Browser
Client-side SDK with real-time WebSocket subscriptions, auto-reconnect, and E2E decryption
ASP
Agent Session Protocol client for sessions, trust scoring, commitments, and negotiation
Installation
# Server-side
npm install @npayload/node
# React hooks
npm install @npayload/react
# Browser client
npm install @npayload/jsQuick 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?