Trigger the workflow from the next.js app.
I created workflow. When i trigger it from web app I see notification in my app. But when I trigger it from my app I do not seen this new notification. I deploy novu locally and I work with my next.js app.
trigger method provided by the Novu Node.js SDK. Here's an example of how you might trigger a notification from an API route in your Next.js app:







REACT_APP_API_URL commented and use NODE_ENV=productionNODE_ENV=productionimport { Novu } from '@novu/node';
const novu = new Novu('<YOUR_NOVU_API_KEY>');
export default async function handler(req, res) {
try {
await novu.trigger('workflow-identifier', {
to: {
subscriberId: 'subscriber-id',
},
payload: {
title: 'Notification Title',
message: 'Notification Message',
},
});
res.status(200).json({ message: 'Notification triggered successfully!' });
} catch (error) {
console.error('Error triggering notification:', error);
res.status(500).json({ error: 'Failed to trigger notification' });
}
}import { Novu } from '@novu/node';
const novu = new Novu('<YOUR_NOVU_API_KEY>');
export default async function handler(req, res) {
try {
const response = await novu.trigger('workflow-identifier', {
to: {
subscriberId: 'subscriber-id',
},
payload: {
title: 'Notification Title',
message: 'Notification Message',
},
});
console.log('Novu response:', response);
res.status(200).json({ message: 'Notification triggered successfully!' });
} catch (error) {
console.error('Error triggering notification:', error);
res.status(500).json({ error: 'Failed to trigger notification', details: error });
}
}