{"id":3439,"date":"2026-11-17T10:11:58","date_gmt":"2026-11-17T04:41:58","guid":{"rendered":"https:\/\/larapush.com\/blog\/?p=3439"},"modified":"2026-11-17T10:11:58","modified_gmt":"2026-11-17T04:41:58","slug":"send-web-push-notifications-nodejs","status":"publish","type":"post","link":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/","title":{"rendered":"How to Send Web Push Notifications From Node.js"},"content":{"rendered":"\n<p><strong>To send web push notifications from Node.js, install the web-push library, generate a VAPID key pair once, and save each browser&#8217;s push subscription in a database.<\/strong> Then call setVapidDetails with your keys and sendNotification with a subscription and a JSON payload. The library encrypts the message, and the browser&#8217;s push service delivers it to your service worker.<\/p>\n\n\n\n<p>Node.js web push notifications don&#8217;t need Firebase or any paid service on the sending side. The protocol is an open standard, and the open-source <a href=\"https:\/\/github.com\/web-push-libs\/web-push\" target=\"_blank\" rel=\"noreferrer noopener\">web-push library<\/a> handles the hard parts: VAPID signing and payload encryption. Below I cover the full flow, with code checked against web-push 4.0, the current version in November 2026.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_63 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#What_do_you_need_to_send_Nodejs_web_push_notifications\" title=\"What do you need to send Node.js web push notifications?\">What do you need to send Node.js web push notifications?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#How_do_you_install_web-push_and_create_VAPID_keys\" title=\"How do you install web-push and create VAPID keys?\">How do you install web-push and create VAPID keys?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#How_do_you_collect_push_subscriptions_in_the_browser\" title=\"How do you collect push subscriptions in the browser?\">How do you collect push subscriptions in the browser?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#How_do_you_send_a_notification_with_web-push\" title=\"How do you send a notification with web-push?\">How do you send a notification with web-push?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#Which_sendNotification_options_matter\" title=\"Which sendNotification options matter?\">Which sendNotification options matter?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#How_do_you_handle_expired_subscriptions_and_errors\" title=\"How do you handle expired subscriptions and errors?\">How do you handle expired subscriptions and errors?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#Does_Nodejs_web_push_reach_iPhone_users\" title=\"Does Node.js web push reach iPhone users?\">Does Node.js web push reach iPhone users?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#Should_you_build_it_yourself_or_use_a_push_panel\" title=\"Should you build it yourself or use a push panel?\">Should you build it yourself or use a push panel?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#Where_does_LaraPush_fit\" title=\"Where does LaraPush fit?\">Where does LaraPush fit?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#Frequently_asked_questions\" title=\"Frequently asked questions\">Frequently asked questions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_do_you_need_to_send_Nodejs_web_push_notifications\"><\/span>What do you need to send Node.js web push notifications?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You need five pieces: HTTPS, a VAPID key pair, a service worker, a subscription store and a sender. Here&#8217;s what each one does.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Piece<\/th><th>Purpose<\/th><th>Notes<\/th><\/tr><\/thead><tbody><tr><td>HTTPS site<\/td><td>Service workers only run in secure contexts<\/td><td>localhost works for testing<\/td><\/tr><tr><td>VAPID key pair<\/td><td>Identifies your server to push services<\/td><td>Generate once; keep the private key secret<\/td><\/tr><tr><td>Service worker<\/td><td>Receives the push event and shows the notification<\/td><td>Serve it from your own domain<\/td><\/tr><tr><td>Subscription store<\/td><td>Saves each browser&#8217;s endpoint and keys<\/td><td>One row per browser, not per user<\/td><\/tr><tr><td>web-push package<\/td><td>Encrypts and sends each message<\/td><td>Version 4 needs Node.js 16 or newer<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The browser side is the same whatever language your server uses. So if you&#8217;ve read my <a href=\"https:\/\/larapush.com\/blog\/send-web-push-php-laravel\/\">PHP and Laravel guide<\/a>, only the server code below is new.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_install_web-push_and_create_VAPID_keys\"><\/span>How do you install web-push and create VAPID keys?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Install the package from npm, then generate the keys once with its command-line tool. Don&#8217;t generate new keys on every deploy, because existing subscriptions only work with the public key they were created with.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install web-push\nnpx web-push generate-vapid-keys --json<\/code><\/pre>\n\n\n\n<p>Save the two values as environment variables, for example VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY. The public key goes to the browser. The private key stays on your server. My explainer on <a href=\"https:\/\/larapush.com\/blog\/vapid-keys-web-push\/\">VAPID keys for web push<\/a> covers what each key does and why losing the private key cuts you off from your subscribers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_collect_push_subscriptions_in_the_browser\"><\/span>How do you collect push subscriptions in the browser?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The browser creates a subscription when the visitor allows notifications. Your page registers a service worker, asks for permission on a click, calls pushManager.subscribe with your public key, and posts the result to your server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ public\/sw.js\nself.addEventListener('push', (event) =&gt; {\n  const data = event.data ? event.data.json() : {};\n  event.waitUntil(\n    self.registration.showNotification(data.title || 'New update', {\n      body: data.body,\n      icon: data.icon,\n      data: { url: data.url || '\/' }\n    })\n  );\n});\n\nself.addEventListener('notificationclick', (event) =&gt; {\n  event.notification.close();\n  event.waitUntil(clients.openWindow(event.notification.data.url));\n});<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ on your page, inside a button click handler\nconst reg = await navigator.serviceWorker.register('\/sw.js');\nconst sub = await reg.pushManager.subscribe({\n  userVisibleOnly: true,\n  applicationServerKey: VAPID_PUBLIC_KEY \/\/ the public key string\n});\nawait fetch('\/api\/subscribe', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application\/json' },\n  body: JSON.stringify(sub)\n});<\/code><\/pre>\n\n\n\n<p>The web-push README shows the public key passed as a string, which current browsers accept. Some older tutorials convert it to a Uint8Array first; that works too. For more on scope and caching, see my guide to <a href=\"https:\/\/larapush.com\/blog\/service-worker-for-web-push\/\">the service worker for web push<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_send_a_notification_with_web-push\"><\/span>How do you send a notification with web-push?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Set your VAPID details once, then call sendNotification for each subscription. Version 4 of web-push is an ES module without a default export, so import it as a namespace. On recent Node.js releases (20.19+ and 22.12+), require(&#8216;web-push&#8217;) also works.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ server.mjs (Express)\nimport express from 'express';\nimport * as webpush from 'web-push';\n\nwebpush.setVapidDetails(\n  'mailto:you@example.com',\n  process.env.VAPID_PUBLIC_KEY,\n  process.env.VAPID_PRIVATE_KEY\n);\n\nconst app = express();\napp.use(express.json());\nconst subscriptions = new Map(); \/\/ use a real database in production\n\napp.post('\/api\/subscribe', (req, res) =&gt; {\n  subscriptions.set(req.body.endpoint, req.body);\n  res.sendStatus(201);\n});\n\napp.post('\/api\/send', async (req, res) =&gt; {\n  const payload = JSON.stringify({\n    title: 'New post: Node.js web push',\n    body: 'Read the step-by-step guide',\n    url: '\/blog\/nodejs-web-push\/'\n  });\n  for (const sub of subscriptions.values()) {\n    try {\n      await webpush.sendNotification(sub, payload, { TTL: 3600, urgency: 'normal' });\n    } catch (err) {\n      if (err instanceof webpush.WebPushError &amp;&amp; (err.statusCode === 404 || err.statusCode === 410)) {\n        subscriptions.delete(sub.endpoint); \/\/ expired or unsubscribed\n      } else {\n        console.error(err.statusCode, err.body);\n      }\n    }\n  }\n  res.sendStatus(202);\n});\n\napp.listen(3000);<\/code><\/pre>\n\n\n\n<p>The subject must be a mailto: address or an https: URL that push services can use to contact you. The web-push README notes that Safari&#8217;s push endpoint rejects a subject pointing at https:\/\/localhost, so use a real address even in testing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Which_sendNotification_options_matter\"><\/span>Which sendNotification options matter?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Three options matter for most sends: TTL, urgency and topic. They map to headers defined in <a href=\"https:\/\/www.rfc-editor.org\/rfc\/rfc8030\" target=\"_blank\" rel=\"noreferrer noopener\">RFC 8030<\/a>, the Web Push protocol.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Option<\/th><th>What it does<\/th><th>Default in web-push<\/th><\/tr><\/thead><tbody><tr><td>TTL<\/td><td>Seconds the push service keeps the message if the device is offline<\/td><td>Four weeks<\/td><\/tr><tr><td>urgency<\/td><td>very-low, low, normal or high; affects battery-saving delivery<\/td><td>normal<\/td><\/tr><tr><td>topic<\/td><td>Replaces an older undelivered message with the same topic<\/td><td>None<\/td><\/tr><tr><td>timeout<\/td><td>Socket timeout in milliseconds<\/td><td>None<\/td><\/tr><tr><td>headers<\/td><td>Extra request headers<\/td><td>None<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For news, a TTL of a few hours stops yesterday&#8217;s headline from arriving tomorrow. For a one-time code or alert, use a short TTL and high urgency. Also keep payloads small: RFC 8030 only requires push services to accept 4,096 bytes, so send a title, body and URL, not a full article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_handle_expired_subscriptions_and_errors\"><\/span>How do you handle expired subscriptions and errors?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Delete a subscription when the push service answers 404 or 410. Those codes mean the subscription has expired or the visitor has unsubscribed, so retrying wastes requests. web-push throws a WebPushError with statusCode, headers and body, which makes the check simple.<\/p>\n\n\n\n<p>Other errors need different handling:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>400 or 403<\/strong>: usually a VAPID problem, such as a key mismatch or a bad subject. Check that the public key in the browser matches the private key on the server.<\/li>\n\n\n\n<li><strong>413<\/strong>: the payload is too large. Trim it.<\/li>\n\n\n\n<li><strong>429<\/strong>: you&#8217;re being rate limited. Back off and retry later.<\/li>\n<\/ul>\n\n\n\n<p>At larger lists, don&#8217;t loop with await one by one. Send in batches with a concurrency limit, or put sends on a queue such as BullMQ, so one slow endpoint doesn&#8217;t hold up everyone else. MDN&#8217;s <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Push_API\" target=\"_blank\" rel=\"noreferrer noopener\">Push API reference<\/a> covers the browser side of the same flow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Does_Nodejs_web_push_reach_iPhone_users\"><\/span>Does Node.js web push reach iPhone users?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Yes. Since iOS 16.4, Safari supports web push for sites added to the Home Screen, and web-push sends to Apple&#8217;s endpoint like any other. You need a web app manifest, and the visitor must add your site to the Home Screen before they can subscribe. See <a href=\"https:\/\/larapush.com\/blog\/how-to-get-web-push-working-on-iphone\/\">how to get web push working on iPhone<\/a> for the full checklist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Should_you_build_it_yourself_or_use_a_push_panel\"><\/span>Should you build it yourself or use a push panel?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Build it yourself if you only need a few alerts triggered by code and you have developers to maintain them. Use a panel if marketers or editors will send campaigns, because the DIY route gives you delivery but no editor, scheduling, segments or reports.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Need<\/th><th>DIY with web-push<\/th><th>Push panel<\/th><\/tr><\/thead><tbody><tr><td>Send an alert from code<\/td><td>Good fit<\/td><td>Works through an API<\/td><\/tr><tr><td>Campaign editor and scheduling<\/td><td>You build it<\/td><td>Included<\/td><\/tr><tr><td>Segments and click reports<\/td><td>You build it<\/td><td>Included<\/td><\/tr><tr><td>Expired subscription cleanup<\/td><td>You build it<\/td><td>Handled for you<\/td><\/tr><tr><td>Main cost<\/td><td>Developer time<\/td><td>Subscription or licence<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If you&#8217;re on Next.js, my guide to <a href=\"https:\/\/larapush.com\/blog\/add-web-push-notifications-to-nextjs\/\">adding web push to Next.js<\/a> shows the same library inside Server Actions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Where_does_LaraPush_fit\"><\/span>Where does LaraPush fit?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>LaraPush is a self-hosted web push panel you install on your own VPS. It handles subscriptions, campaigns, scheduling, segmentation and click reports, and its REST API has no call limits, so your Node.js app can trigger sends instead of encrypting messages itself. See the <a href=\"https:\/\/larapush.com\/features\/\">features overview<\/a>, the <a href=\"https:\/\/larapush.com\/guide\/\">setup guide<\/a> and my notes on the <a href=\"https:\/\/larapush.com\/blog\/push-notification-api-for-developers\/\">push notification API for developers<\/a>.<\/p>\n\n\n\n<p>The trade-offs: you run the server, the licence covers one server, and there&#8217;s no free plan. Plans start from $499 one-time; check the <a href=\"https:\/\/larapush.com\/pricing\/\">pricing page<\/a> for current prices. For a wider view, my <a href=\"https:\/\/larapush.com\/blog\/best-push-notification-services-and-tools\/\">roundup of push notification services<\/a> compares SaaS and self-hosted tools.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1763370000000\"><strong class=\"schema-faq-question\">Do I need Firebase to send web push from Node.js?<\/strong> <p class=\"schema-faq-answer\">No. The web-push library sends straight to each browser&#8217;s push service using VAPID, so you don&#8217;t need a Firebase project or server key. Chrome subscriptions still travel through Google&#8217;s push service, but your code only needs the subscription endpoint and your VAPID keys.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763370001111\"><strong class=\"schema-faq-question\">Why does web-push fail with &#8220;does not provide an export named default&#8221;?<\/strong> <p class=\"schema-faq-answer\">Version 4 of web-push is an ES module without a default export. Import it with import * as webpush from &#8216;web-push&#8217;, or import the functions you need by name, such as sendNotification and setVapidDetails.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763370002222\"><strong class=\"schema-faq-question\">How many notifications can Node.js send at once?<\/strong> <p class=\"schema-faq-answer\">There&#8217;s no fixed limit in web-push itself; each send is one HTTPS request. Throughput depends on your server, network and concurrency. For large lists, send in batches or through a job queue, and remove subscriptions that return 404 or 410.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763370003333\"><strong class=\"schema-faq-question\">Can I send a push without a payload?<\/strong> <p class=\"schema-faq-answer\">Yes. sendNotification accepts no payload, and the service worker still gets a push event. It must then show a notification anyway, because browsers require a visible notification for each push, so most sites send a small JSON payload instead.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763370004444\"><strong class=\"schema-faq-question\">What is the subject in setVapidDetails?<\/strong> <p class=\"schema-faq-answer\">It&#8217;s a contact point for push services, either a mailto: email address or an https: URL. Push services can use it to reach you if your sends cause problems. Avoid an https:\/\/localhost subject, which Safari&#8217;s push endpoint rejects.<\/p> <\/div><\/div>\n","protected":false},"excerpt":{"rendered":"How to send web push notifications from Node.js with the web-push library: VAPID keys, subscriptions, sending code and error handling.","protected":false},"author":7,"featured_media":3449,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":""},"categories":[68],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Send Web Push Notifications From Node.js<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Send Web Push Notifications From Node.js\" \/>\n<meta property=\"og:description\" content=\"How to send web push notifications from Node.js with the web-push library: VAPID keys, subscriptions, sending code and error handling.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\" \/>\n<meta property=\"og:site_name\" content=\"LaraPush Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-17T04:41:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ritesh Das\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ritesh Das\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\"},\"author\":{\"name\":\"Ritesh Das\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd\"},\"headline\":\"How to Send Web Push Notifications From Node.js\",\"datePublished\":\"2026-11-17T04:41:58+00:00\",\"dateModified\":\"2026-11-17T04:41:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\"},\"wordCount\":1361,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/larapush.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg\",\"articleSection\":[\"How to\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\",\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\",\"name\":\"How to Send Web Push Notifications From Node.js\",\"isPartOf\":{\"@id\":\"https:\/\/larapush.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg\",\"datePublished\":\"2026-11-17T04:41:58+00:00\",\"dateModified\":\"2026-11-17T04:41:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000\"},{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111\"},{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222\"},{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333\"},{\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage\",\"url\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg\",\"contentUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg\",\"width\":1200,\"height\":675,\"caption\":\"Illustration of a server sending Node.js web push notifications to a browser\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/larapush.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Send Web Push Notifications From Node.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/larapush.com\/blog\/#website\",\"url\":\"https:\/\/larapush.com\/blog\/\",\"name\":\"LaraPush Blog\",\"description\":\"Stay Ahead, Stay Notified with LaraPush!\",\"publisher\":{\"@id\":\"https:\/\/larapush.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/larapush.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/larapush.com\/blog\/#organization\",\"name\":\"LaraPush\",\"url\":\"https:\/\/larapush.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png\",\"contentUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png\",\"width\":280,\"height\":60,\"caption\":\"LaraPush\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd\",\"name\":\"Ritesh Das\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g\",\"caption\":\"Ritesh Das\"},\"url\":\"https:\/\/larapush.com\/blog\/author\/riteshdas\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000\",\"position\":1,\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000\",\"name\":\"Do I need Firebase to send web push from Node.js?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. The web-push library sends straight to each browser's push service using VAPID, so you don't need a Firebase project or server key. Chrome subscriptions still travel through Google's push service, but your code only needs the subscription endpoint and your VAPID keys.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111\",\"position\":2,\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111\",\"name\":\"Why does web-push fail with \\\"does not provide an export named default\\\"?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Version 4 of web-push is an ES module without a default export. Import it with import * as webpush from 'web-push', or import the functions you need by name, such as sendNotification and setVapidDetails.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222\",\"position\":3,\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222\",\"name\":\"How many notifications can Node.js send at once?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"There's no fixed limit in web-push itself; each send is one HTTPS request. Throughput depends on your server, network and concurrency. For large lists, send in batches or through a job queue, and remove subscriptions that return 404 or 410.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333\",\"position\":4,\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333\",\"name\":\"Can I send a push without a payload?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. sendNotification accepts no payload, and the service worker still gets a push event. It must then show a notification anyway, because browsers require a visible notification for each push, so most sites send a small JSON payload instead.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444\",\"position\":5,\"url\":\"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444\",\"name\":\"What is the subject in setVapidDetails?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It's a contact point for push services, either a mailto: email address or an https: URL. Push services can use it to reach you if your sends cause problems. Avoid an https:\/\/localhost subject, which Safari's push endpoint rejects.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Send Web Push Notifications From Node.js","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/","og_locale":"en_US","og_type":"article","og_title":"How to Send Web Push Notifications From Node.js","og_description":"How to send web push notifications from Node.js with the web-push library: VAPID keys, subscriptions, sending code and error handling.","og_url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/","og_site_name":"LaraPush Blog","article_published_time":"2026-11-17T04:41:58+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg","type":"image\/jpeg"}],"author":"Ritesh Das","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ritesh Das","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#article","isPartOf":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/"},"author":{"name":"Ritesh Das","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd"},"headline":"How to Send Web Push Notifications From Node.js","datePublished":"2026-11-17T04:41:58+00:00","dateModified":"2026-11-17T04:41:58+00:00","mainEntityOfPage":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/"},"wordCount":1361,"commentCount":0,"publisher":{"@id":"https:\/\/larapush.com\/blog\/#organization"},"image":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg","articleSection":["How to"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/","url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/","name":"How to Send Web Push Notifications From Node.js","isPartOf":{"@id":"https:\/\/larapush.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage"},"image":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg","datePublished":"2026-11-17T04:41:58+00:00","dateModified":"2026-11-17T04:41:58+00:00","breadcrumb":{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000"},{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111"},{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222"},{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333"},{"@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#primaryimage","url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg","contentUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/send-web-push-notifications-nodejs.jpg","width":1200,"height":675,"caption":"Illustration of a server sending Node.js web push notifications to a browser"},{"@type":"BreadcrumbList","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/larapush.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Send Web Push Notifications From Node.js"}]},{"@type":"WebSite","@id":"https:\/\/larapush.com\/blog\/#website","url":"https:\/\/larapush.com\/blog\/","name":"LaraPush Blog","description":"Stay Ahead, Stay Notified with LaraPush!","publisher":{"@id":"https:\/\/larapush.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/larapush.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/larapush.com\/blog\/#organization","name":"LaraPush","url":"https:\/\/larapush.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png","contentUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png","width":280,"height":60,"caption":"LaraPush"},"image":{"@id":"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd","name":"Ritesh Das","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g","caption":"Ritesh Das"},"url":"https:\/\/larapush.com\/blog\/author\/riteshdas\/"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000","position":1,"url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370000000","name":"Do I need Firebase to send web push from Node.js?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"No. The web-push library sends straight to each browser's push service using VAPID, so you don't need a Firebase project or server key. Chrome subscriptions still travel through Google's push service, but your code only needs the subscription endpoint and your VAPID keys.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111","position":2,"url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370001111","name":"Why does web-push fail with \"does not provide an export named default\"?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Version 4 of web-push is an ES module without a default export. Import it with import * as webpush from 'web-push', or import the functions you need by name, such as sendNotification and setVapidDetails.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222","position":3,"url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370002222","name":"How many notifications can Node.js send at once?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"There's no fixed limit in web-push itself; each send is one HTTPS request. Throughput depends on your server, network and concurrency. For large lists, send in batches or through a job queue, and remove subscriptions that return 404 or 410.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333","position":4,"url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370003333","name":"Can I send a push without a payload?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes. sendNotification accepts no payload, and the service worker still gets a push event. It must then show a notification anyway, because browsers require a visible notification for each push, so most sites send a small JSON payload instead.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444","position":5,"url":"https:\/\/larapush.com\/blog\/send-web-push-notifications-nodejs\/#faq-question-1763370004444","name":"What is the subject in setVapidDetails?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It's a contact point for push services, either a mailto: email address or an https: URL. Push services can use it to reach you if your sends cause problems. Avoid an https:\/\/localhost subject, which Safari's push endpoint rejects.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3439"}],"collection":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/comments?post=3439"}],"version-history":[{"count":1,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3439\/revisions"}],"predecessor-version":[{"id":3444,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3439\/revisions\/3444"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/media\/3449"}],"wp:attachment":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/media?parent=3439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/categories?post=3439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/tags?post=3439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}