-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #685 from novuhq/v2-headless-docs
[WIP] feat: add v2 headless doc
- Loading branch information
Showing
10 changed files
with
811 additions
and
103 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
title: 'Headless Inbox' | ||
sidebarTitle: 'Get Started' | ||
description: 'A lightweight, standalone package for building custom in-app notification interfaces with Novu, providing essential functionalities and flexibility.' | ||
--- | ||
|
||
The headless version of Novu’s notification library package provides users with a lightweight solution for integrating notification functionality into their web applications. With just the essential API methods, users can easily incorporate our notification system into any framework or vanilla JavaScript project, without being constrained by our default UI or dependencies. The SDK includes real-time notifications through a WebSocket connection and can be safely used across web browsers. | ||
|
||
## Get Started | ||
|
||
<Steps> | ||
<Step title="Installation"> | ||
```bash | ||
npm install @novu/js | ||
``` | ||
</Step> | ||
<Step title="Import Package"> | ||
```typescript | ||
import { Novu } from "@novu/js"; | ||
``` | ||
</Step> | ||
<Step title="Initialize Session"> | ||
<Tabs> | ||
<Tab title="US" > | ||
```typescript | ||
import { Novu } from "@novu/js"; | ||
|
||
const novu = new Novu({ | ||
subscriberId: "SUBSCRIBER_ID", | ||
applicationIdentifier: "APPLICATION_IDENTIFIER", | ||
}); | ||
``` | ||
</Tab> | ||
<Tab title="EU"> | ||
```typescript | ||
import { Novu } from "@novu/js"; | ||
|
||
const novu = new Novu({ | ||
subscriberId: "SUBSCRIBER_ID", | ||
applicationIdentifier: "APPLICATION_IDENTIFIER", | ||
backendUrl: "https://eu.api.novu.co", | ||
socketUrl: "https://eu.ws.novu.co", | ||
}); | ||
``` | ||
</Tab> | ||
<Tab title="HMAC Encryption"> | ||
Read more about [HMAC Encryption](/react/advanced-configuration#hmac-encryption). | ||
```typescript | ||
import { Novu } from "@novu/js"; | ||
|
||
const novu = new Novu({ | ||
subscriberId: "SUBSCRIBER_ID", | ||
applicationIdentifier: "APPLICATION_IDENTIFIER", | ||
subscriberHash: "SUBSCRIBER_HASH_HMAC_SUBSCRIBER_HASH_HMAC_ENCRYPTION", | ||
}); | ||
``` | ||
</Tab> | ||
</Tabs> | ||
</Step> | ||
<Step title="Fetch Notifications"> | ||
```typescript | ||
const response = await novu.notifications.list({ | ||
limit: 30, | ||
}); | ||
|
||
const notifications = response.data.notifications | ||
``` | ||
</Step> | ||
<Step> | ||
Display `notifications` in your UI. | ||
</Step> | ||
</Steps> | ||
|
||
## Realtime Notifications | ||
Events are emitted when notifications are received, and when the unread notificatons count changes. `novu.on()` is used to listen to these events. | ||
```typescript | ||
novu.on("notifications.notification_received", (data) => { | ||
console.log("new notification =>", data); | ||
}); | ||
|
||
novu.on("notifications.unread_count_changed", (data) => { | ||
console.log("new unread notifications count =>", data); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.