🔔 Notifications
Using NotifyClient
The NotifyClient from @oneclick.dev/sdk lets you send push notifications directly to specific users in a project. Use it to notify users about events, updates, or actions from any app or service.
🚀 Installation
Install the SDK via your preferred package manager:
# npm
npm install @oneclick.dev/sdk
# pnpm
pnpm add @oneclick.dev/sdk
# yarn
yarn add @oneclick.dev/sdk
✨ Getting Started
Import and Create a Client
import { NotifyClient } from '@oneclick.dev/sdk'
const notifier = new NotifyClient({
endpoint: "https://cms.yourdomain.com",
key: "your-api-key",
project: "your-project"
})
Make sure the API key has the correct permissions to send notifications.
📣 Sending Notifications
Use notifier.send()
to deliver a notification:
await notifier.send({
title: 'New Comment',
message: 'A user left a new comment on your post.',
userId: 'user_123' // Optional: send to a specific user
})
userId
can be omitted to notify all users, or set to a single user ID or an array of user IDs to target specific users.
💡 Example Use Cases
Notify a single user about a new message:
await notifier.send({
title: 'You have a new message',
message: 'Click here to read it.',
userId: 'user_456'
})
Broadcast a system-wide announcement:
await notifier.send({
title: 'Maintenance Notice',
message: 'We will be down for maintenance at 2 AM UTC.'
})