File tree 2 files changed +33
-1
lines changed
packages/nextjs/src/pages-router
playground/nextjs/src/app/inbox-client
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
1
'use client' ;
2
2
3
3
import { InboxProps , Inbox as RInbox } from '@novu/react' ;
4
- import { useRouter } from 'next/router' ;
4
+ import { useRouter as useAppRouter } from 'next/navigation' ;
5
+ import { useRouter } from 'next/compat/router' ;
6
+
7
+ function AppRouterInbox ( props : InboxProps ) {
8
+ const router = useAppRouter ( ) ;
9
+
10
+ return < RInbox routerPush = { router . push } { ...props } /> ;
11
+ }
5
12
6
13
export function Inbox ( props : InboxProps ) {
7
14
const router = useRouter ( ) ;
8
15
16
+ if ( ! router ) {
17
+ return < AppRouterInbox { ...props } /> ;
18
+ }
19
+
9
20
return < RInbox routerPush = { router . push } { ...props } /> ;
10
21
}
11
22
Original file line number Diff line number Diff line change
1
+ 'use client' ;
2
+
3
+ import { novuConfig } from '@/utils/config' ;
4
+ import { Inbox , Notifications , Preferences } from '@novu/nextjs' ;
5
+
6
+ export default function InboxPage ( ) {
7
+ return (
8
+ < >
9
+ < h1 > Hello from Inbox page</ h1 >
10
+ < div className = "flex flex-col gap-4" >
11
+ < h1 > App Router</ h1 >
12
+ < Inbox { ...novuConfig } >
13
+ < h2 > My custom Inbox</ h2 >
14
+ < Preferences />
15
+ < Notifications />
16
+ </ Inbox >
17
+ < Inbox { ...novuConfig } />
18
+ </ div >
19
+ </ >
20
+ ) ;
21
+ }
You can’t perform that action at this time.
0 commit comments