最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to get Real-time in-app notifications with Novu? - Stack Overflow

programmeradmin3浏览0评论

I am trying to receive real-time notifications without the need to refresh using Novu. Following the guide here at novu docs, i created the layout.tsx like

import { NotificationInbox } from "@/components/inbox"; 
 
export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <nav>
          <NotificationInbox />
        </nav>
        {children}
      </body>
    </html>
  );
}

and NotificationInbox.tsx like this

'use client';
import React from 'react';
import { Inbox } from '@novu/nextjs';
 
 
export function NotificationInbox() {
  return (
    <Inbox
      applicationIdentifier="YOUR_APPLICATION_IDENTIFIER"
      subscriberId="YOUR_SUBSCRIBER_ID"
    />
  );
}

When i trigger my workflow from the dashboard, i have to refresh my nextjs app to see the latest notification.

How can i do this every time a notification is sent from novu? Without the need for refreshing manually to some periodic refresh of n minutes

I am trying to receive real-time notifications without the need to refresh using Novu. Following the guide here at novu docs, i created the layout.tsx like

import { NotificationInbox } from "@/components/inbox"; 
 
export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <nav>
          <NotificationInbox />
        </nav>
        {children}
      </body>
    </html>
  );
}

and NotificationInbox.tsx like this

'use client';
import React from 'react';
import { Inbox } from '@novu/nextjs';
 
 
export function NotificationInbox() {
  return (
    <Inbox
      applicationIdentifier="YOUR_APPLICATION_IDENTIFIER"
      subscriberId="YOUR_SUBSCRIBER_ID"
    />
  );
}

When i trigger my workflow from the dashboard, i have to refresh my nextjs app to see the latest notification.

How can i do this every time a notification is sent from novu? Without the need for refreshing manually to some periodic refresh of n minutes

Share Improve this question asked Mar 17 at 12:32 SarmadSarmad 3054 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

To the Inbox component, adding socketUrl does the job. I can now receive real-time notifications with this

<Inbox
  socketUrl="https://eu.ws.novu.co"
  backendUrl="https://eu.api.novu.co"
  applicationIdentifier="APP_ID"
  subscriberId="SUBSCRIBER_ID"
>
发布评论

评论列表(0)

  1. 暂无评论