{"id":19663,"date":"2026-11-19T01:28:50","date_gmt":"2026-11-18T19:58:50","guid":{"rendered":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/"},"modified":"2026-11-19T02:04:46","modified_gmt":"2026-11-18T20:34:46","slug":"otp-widget-nodejs-express-fast2sms","status":"publish","type":"post","link":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/","title":{"rendered":"Node.js Express OTP verification with the Fast2SMS OTP widget"},"content":{"rendered":"<p>This guide adds Node.js OTP verification to an Express app with the Fast2SMS <a href=\"\/help\/otp-verification-widget-fast2sms\/\">OTP widget<\/a>. You get a ready <code>POST \/f2s-otp<\/code> endpoint that holds your API key and calls Fast2SMS Smart OTP, plus a browser box with code inputs and a resend timer. Visitors verify their mobile number by SMS or WhatsApp, and your server gets a signed token it can trust.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Add OTP verification to your Express app<\/strong><p>Create a Smart OTP template, copy the OTP ID and run the Node kit.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<p class=\"f2s-kit-wrap\"><a class=\"f2s-kit\" href=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/fast2sms-otp-widget-node-express.zip\" download><svg class=\"f2s-kit__icon\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#7F56D9\" d=\"M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z\"\/><path fill=\"#FFFFFF\" d=\"M14 2v6h6\"\/><path fill=\"#FFFFFF\" d=\"M9 6h2v2H9zm2 2h2v2h-2zM9 10h2v2H9zm2 2h2v2h-2zm-2 2h4v4H9z\"\/><rect x=\"10\" y=\"15.4\" width=\"2\" height=\"1.6\" fill=\"#7F56D9\"\/><\/svg><span class=\"f2s-kit__text\"><strong>Download the Node.js Express OTP widget kit (zip)<\/strong><span class=\"f2s-kit__meta\">fast2sms-otp-widget-node-express.zip &middot; 57 KB<\/span><\/span><span class=\"f2s-kit__btn\">Download .zip<\/span><\/a><\/p>\n<div class=\"f2s-note\">We tested this kit with Node.js 24.18.0 and Express 5 against a mock copy of the Fast2SMS API, so no real SMS was sent: 47 of 47 browser and API checks and 6 of 6 unit tests passed.<\/div>\n<h2>Before you start<\/h2>\n<ul>\n<li>A Fast2SMS account with wallet balance, and an approved DLT OTP template (for SMS) or WhatsApp Authentication\/Utility template (for WhatsApp).<\/li>\n<li>Node.js 20.12 or newer. The kit reads <code>.env<\/code> with Node&#8217;s built-in <code>process.loadEnvFile<\/code>, so it needs no dotenv package.<\/li>\n<\/ul>\n<h2>Set up Node.js OTP verification<\/h2>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Create a Smart OTP template and copy its OTP ID<\/h3>\n<p>In the panel, open <strong>Smart OTP<\/strong> &gt; <strong>OTP Template List<\/strong> and click <strong>Add OTP Template<\/strong>. On the <strong>SMS Channel<\/strong> tab, pick your DLT entity, sender and approved OTP template, then click the variable that should carry the code. For WhatsApp, use the <strong>WhatsApp Channel<\/strong> tab with an approved Authentication or Utility template. Tick <strong>SET FALLBACK TEMPLATE<\/strong> if you want the other channel as a backup, then click <strong>Assign OTP Template<\/strong>.<\/p>\n<p>Copy the 10-character <strong>OTP ID<\/strong> from the new card. It decides the channel, the template and the fallback for every code the widget sends.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Smart OTP Template list with SMS and WhatsApp template cards, each showing its OTP ID with a copy icon\"><figcaption>Each template card shows its 10-character OTP ID with a copy icon.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Copy your API key<\/h3>\n<p>Under <strong>Utility<\/strong> in the left menu, click <strong>API Key<\/strong>. Click <strong>View<\/strong> (the panel first asks for an OTP sent to your registered mobile) and copy the <strong>Authorization Key<\/strong>. Check that <strong>API Access<\/strong> is switched on. This key will live only in your backend&#8217;s settings, never in a page or an app.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/api-key-hd-33-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"API Key page with the masked Authorization Key, View and Reset buttons and the API Access switch turned on\"><figcaption>Copy the Authorization Key. API Access must be on.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Install and fill in .env<\/h3>\n<p>Unzip the kit, then:<\/p>\n<pre><code class=\"language-bash\">npm install\ncp .env.example .env<\/code><\/pre>\n<p>Open <code>.env<\/code> and set the three required values. The file&#8217;s comment shows a one-line command that makes a random secret.<\/p>\n<pre><code class=\"language-bash\">FAST2SMS_API_KEY=YOUR_API_KEY\nF2S_OTP_ID=YOUR_OTP_ID\nF2S_TOKEN_SECRET=at-least-32-random-characters<\/code><\/pre>\n<p>Never commit <code>.env<\/code>. The kit&#8217;s <code>.gitignore<\/code> already lists it.<\/p>\n<\/li>\n<li>\n<h3>Run the demo<\/h3>\n<p>Run <code>npm start<\/code> and open <code>http:\/\/127.0.0.1:3000<\/code>. The demo page has a login box and a sign-up form that needs a verified number. If a required setting is missing, the server does not start and prints which one.<\/p>\n<\/li>\n<li>\n<h3>Add the endpoint to your own app<\/h3>\n<p>Copy <code>f2s-otp-core.mjs<\/code> into your project. It has no dependencies. Then add the route from <code>server.mjs<\/code>:<\/p>\n<pre><code class=\"language-javascript\">import express from 'express';\nimport { loadConfig, createOtpEndpoint } from '.\/f2s-otp-core.mjs';\n\nconst otp = createOtpEndpoint(loadConfig(process.env)); \/\/ throws if a required setting is missing\nconst app = express();\n\napp.all('\/f2s-otp', express.json({ limit: '8kb' }), async (req, res) =&gt; {\n  const r = await otp.handle({\n    method: req.method,\n    headers: req.headers,\n    body: req.is('application\/json') ? req.body : null,\n    ip: String(req.ip || '').replace(\/^::ffff:\/, ''),\n    host: req.headers.host,\n  });\n  res.status(r.status).set(r.headers);\n  if (r.body === null) res.end();\n  else res.send(JSON.stringify(r.body));\n});<\/code><\/pre>\n<p>Serve <code>f2s-otp-widget.min.js<\/code> as a static file and add the widget to your page:<\/p>\n<pre><code class=\"language-html\">&lt;script src=\"\/f2s-otp-widget.min.js\" defer&gt;&lt;\/script&gt;\n&lt;div data-f2s-otp data-endpoint=\"\/f2s-otp\"&gt;&lt;\/div&gt;<\/code><\/pre>\n<\/li>\n<li>\n<h3>Check the token before you trust the number<\/h3>\n<p>The widget gives your page a token on <code>f2s:verified<\/code>, or puts it in a hidden <code>f2s_token<\/code> field when the form has <code>data-f2s-protect<\/code>. Check it on the server:<\/p>\n<pre><code class=\"language-javascript\">app.post('\/signup', express.urlencoded({ extended: false }), async (req, res) =&gt; {\n  const v = await otp.verifyToken(req.body.f2s_token, { mobile: req.body.phone });\n  if (v === null) return res.status(403).send('Mobile number not verified.');\n  \/\/ v.mobile is the verified 10-digit number. A token works only once.\n  \/\/ create the account or start the session here\n});<\/code><\/pre>\n<p>For OTP login, find the user by <code>v.mobile<\/code> and start the session here. Never log a user in from the browser event alone.<\/p>\n<\/li>\n<\/ol>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Get your OTP ID in a few minutes<\/strong><p>Create a Smart OTP template on SMS or WhatsApp, with fallback, and put it in your .env file.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Going live<\/h2>\n<ul>\n<li><strong>The demo server listens on 127.0.0.1 only.<\/strong> Put it behind nginx or your load balancer, and set <code>F2S_TRUST_PROXY=1<\/code> so the per-IP limit reads the visitor&#8217;s IP from <code>X-Forwarded-For<\/code>. Set it only behind a proxy you control.<\/li>\n<li><strong>Limits live in memory<\/strong>, so they work for one process. With PM2 cluster mode or several servers, pass a shared store: <code>createOtpEndpoint(config, { store })<\/code>. The core includes <code>UpstashRedisStore<\/code>, or write your own with <code>incr<\/code>, <code>get<\/code>, <code>set<\/code> and <code>del<\/code>.<\/li>\n<li><strong>API Security:<\/strong> if it is on in your account, whitelist your server&#8217;s outgoing IP. See <a href=\"\/help\/api-security-ip-whitelist\/\">IP whitelisting<\/a>.<\/li>\n<li><strong>React or Vue front end:<\/strong> the kit&#8217;s examples wrap the same widget. The React example was tested (3 of 3 checks); the Vue example has not been run yet.<\/li>\n<\/ul>\n<h2>Settings<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Setting<\/th>\n<th>Required<\/th>\n<th>Default<\/th>\n<th>What it does<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>FAST2SMS_API_KEY<\/code><\/td>\n<td>Yes<\/td>\n<td><\/td>\n<td>Your API key, the bare key (no <code>Bearer<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_OTP_ID<\/code><\/td>\n<td>Yes<\/td>\n<td><\/td>\n<td>The 10-character OTP ID from the template card<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_TOKEN_SECRET<\/code><\/td>\n<td>Yes<\/td>\n<td><\/td>\n<td>32 or more random characters; signs tickets and tokens<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_OTP_IDS<\/code><\/td>\n<td>No<\/td>\n<td><\/td>\n<td>More OTP IDs a page may pick with <code>data-otp-id<\/code>, comma separated<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_ALLOWED_ORIGINS<\/code><\/td>\n<td>No<\/td>\n<td>same site only<\/td>\n<td>Other sites whose pages may call this backend<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_RESEND_WAIT<\/code><\/td>\n<td>No<\/td>\n<td>30<\/td>\n<td>Seconds between sends to one number<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_LIMIT_PER_NUMBER<\/code><\/td>\n<td>No<\/td>\n<td>5<\/td>\n<td>Sends per number per hour<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_LIMIT_PER_IP<\/code><\/td>\n<td>No<\/td>\n<td>20<\/td>\n<td>Sends per IP address per hour<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_MAX_VERIFY<\/code><\/td>\n<td>No<\/td>\n<td>5<\/td>\n<td>Wrong codes allowed per code<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_TOKEN_TTL<\/code><\/td>\n<td>No<\/td>\n<td>600<\/td>\n<td>Seconds a verified token stays valid<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_OTP_EXPIRY<\/code> \/ <code>F2S_OTP_LENGTH<\/code><\/td>\n<td>No<\/td>\n<td>15 min \/ 6 digits<\/td>\n<td>Code expiry (1 to 10080 minutes) and length (4 to 10)<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_CAPTCHA<\/code> \/ <code>F2S_CAPTCHA_SECRET<\/code><\/td>\n<td>No<\/td>\n<td>off<\/td>\n<td><code>turnstile<\/code> or <code>recaptcha<\/code>, plus its secret key<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>Sending, resending and cost<\/h2>\n<p>The backend checks the page&#8217;s origin, the <code>X-F2S-Widget<\/code> header, the resend wait and the limits before it calls Fast2SMS. It never retries a send that may have reached Fast2SMS, so a timeout cannot charge you twice.<\/p>\n<p><strong>Resend<\/strong> sends the same code again, it does not make a new one. Fast2SMS allows it within 10 minutes of the first send, and up to 5 sends to one number in that time, counting the first.<\/p>\n<p>Every send and every resend is charged at your Smart OTP rate, and a fallback message on the second channel is charged too. Verify is free. The <strong>Test OTP<\/strong> button on a template card is also a real, charged send. See the current rates on the <a href=\"https:\/\/www.fast2sms.com\/otp-sms\">OTP SMS page<\/a>.<\/p>\n<div class=\"f2s-note f2s-volume\"><p><strong>Sending in bulk?<\/strong> For high OTP volumes our team offers discounted rates. <a href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Talk to our team<\/a> or see <a href=\"https:\/\/www.fast2sms.com\/bulk-sms-pricing\">OTP pricing<\/a>.<\/p><\/div>\n<h2>Common problems and fixes<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>What you see<\/th>\n<th>Why<\/th>\n<th>Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>The server exits at start and lists settings<\/td>\n<td>A required setting is missing or wrong<\/td>\n<td>Set <code>FAST2SMS_API_KEY<\/code>, <code>F2S_OTP_ID<\/code> (10 characters) and <code>F2S_TOKEN_SECRET<\/code> (32 or more).<\/td>\n<\/tr>\n<tr>\n<td>&#8220;We could not send the code right now.&#8221;<\/td>\n<td>An account or setup problem. Your server log names it: <code>failed reason=...<\/code><\/td>\n<td><code>invalid_otp_id<\/code>: copy the OTP ID again, from the same account as the key. <code>insufficient_balance<\/code>: recharge with <strong>Add Amount<\/strong>. <code>template_inactive<\/code>: create a new OTP template. Auth error: check the key, switch on <strong>API Access<\/strong>, or whitelist the server IP in <strong>API Security<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;This page is not allowed to use this OTP service.&#8221;<\/td>\n<td>The page is on another domain<\/td>\n<td>Add its origin (<code>https:\/\/<\/code> plus the domain, no path) to <code>F2S_ALLOWED_ORIGINS<\/code>.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Please wait N seconds&#8230;&#8221;<\/td>\n<td>The resend wait: the widget&#8217;s own, or Fast2SMS&#8217;s<\/td>\n<td>Wait. Change <code>F2S_RESEND_WAIT<\/code>, or <strong>SMS Resend \/ Time Limit<\/strong> in <strong>OTP Settings<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Too many requests&#8221;<\/td>\n<td>The per-number or per-IP limit was hit<\/td>\n<td>Wait an hour, or raise <code>F2S_LIMIT_PER_NUMBER<\/code> \/ <code>F2S_LIMIT_PER_IP<\/code>.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Too many wrong tries&#8221;<\/td>\n<td><code>F2S_MAX_VERIFY<\/code>, or <strong>Max Verify OTP Limit<\/strong> in OTP Settings<\/td>\n<td>The visitor asks for a new code.<\/td>\n<\/tr>\n<tr>\n<td>Your form handler says &#8220;not verified&#8221;<\/td>\n<td>The token is missing, was used already, is older than 10 minutes, or is for another number<\/td>\n<td>Verify again. Check the token once, when the form is submitted.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<section class=\"f2s-faq\">\n<h2>Frequently asked questions<\/h2>\n<h3>Which Node.js version does the kit need?<\/h3>\n<p>Node.js 20.12 or newer, with Express 5. It was tested on Node.js 24.18.0.<\/p>\n<h3>Can I use the core without Express?<\/h3>\n<p>Yes. <code>f2s-otp-core.mjs<\/code> has no dependencies and is the same code the Cloudflare Worker, Vercel and Netlify kits use. Pass it the method, headers, body, IP and host of each request.<\/p>\n<h3>Should I call Fast2SMS from my React app directly?<\/h3>\n<p>No. That would put your API key in the browser. The React app talks to your Express endpoint, and only Express talks to Fast2SMS.<\/p>\n<h3>I want a complete OTP login page. Which kit?<\/h3>\n<p>Use the <a href=\"\/help\/otp-login-nodejs-express-fast2sms\/\">Node.js Express OTP login starter kit<\/a>. The widget is for adding verification to pages you already have.<\/p>\n<h3>How do I limit costs from bots?<\/h3>\n<p>Keep the per-number and per-IP limits on, use a shared store when you run more than one process, and switch on the optional Turnstile or reCAPTCHA check with <code>F2S_CAPTCHA<\/code>.<\/p>\n<h3>Is the token a JWT?<\/h3>\n<p>No. It is a short signed string in its own format, made with HMAC-SHA256. Check it only with <code>verifyToken<\/code>, which also makes sure it is used once.<\/p>\n<\/section>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Send OTPs with Fast2SMS<\/strong><p>Sign up and add OTP verification to your Node.js app with Smart OTP.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Related guides<\/h2>\n<ul>\n<li><a href=\"\/help\/otp-login-nodejs-express-fast2sms\/\">Node.js Express OTP login with Fast2SMS Smart OTP (starter kit)<\/a><\/li>\n<li><a href=\"\/help\/nodejs-sms-api\/\">Send SMS and OTP in Node.js with Fast2SMS API<\/a><\/li>\n<li><a href=\"\/help\/smart-otp-setup-guide-fast2sms\/\">Smart OTP in Fast2SMS: set up OTP on SMS and WhatsApp<\/a><\/li>\n<li><a href=\"\/help\/otp-sms-pumping-fraud-protection\/\">OTP fraud and SMS pumping protection<\/a><\/li>\n<li><a href=\"\/help\/api-key-find-reset\/\">How to find, view and reset your Fast2SMS API key<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This guide adds Node.js OTP verification to an Express app with the Fast2SMS OTP widget. You get a ready POST \/f2s-otp endpoint that holds your API key and calls Fast2SMS Smart OTP, plus a browser box with code inputs and a resend timer. Visitors verify their mobile number by SMS or WhatsApp, and your server [&hellip;]<\/p>\n","protected":false},"featured_media":19646,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-19663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api","category-otp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Node.js Express OTP Verification Widget | Fast2SMS<\/title>\n<meta name=\"description\" content=\"Add Node.js OTP verification to your Express app: a ready \/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node.js Express OTP Verification Widget | Fast2SMS\" \/>\n<meta property=\"og:description\" content=\"Add Node.js OTP verification to your Express app: a ready \/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/\" \/>\n<meta property=\"og:site_name\" content=\"Fast2SMS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Fast2SMS\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-18T19:58:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-18T20:34:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fast2sms\" \/>\n<meta name=\"twitter:site\" content=\"@fast2sms\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/\"},\"author\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"headline\":\"Node.js Express OTP verification with the Fast2SMS OTP widget\",\"datePublished\":\"2026-11-18T19:58:50+00:00\",\"dateModified\":\"2026-11-18T20:34:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/\"},\"wordCount\":1382,\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-31-scaled.webp\",\"articleSection\":[\"API\",\"OTP\"],\"inLanguage\":\"en-IN\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/\",\"name\":\"Node.js Express OTP Verification Widget | Fast2SMS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-31-scaled.webp\",\"datePublished\":\"2026-11-18T19:58:50+00:00\",\"dateModified\":\"2026-11-18T20:34:46+00:00\",\"description\":\"Add Node.js OTP verification to your Express app: a ready \\\/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#breadcrumb\"},\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-31-scaled.webp\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-31-scaled.webp\",\"width\":2560,\"height\":1600,\"caption\":\"Smart OTP Template page with WhatsApp and SMS OTP template cards, each showing its OTP ID, sender or number, template ID and fallback\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-nodejs-express-fast2sms\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/api\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Node.js Express OTP verification with the Fast2SMS OTP widget\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\",\"name\":\"Fast2SMS\",\"description\":\"Help\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"inLanguage\":\"en-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\",\"name\":\"Fast2SMS\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"caption\":\"Fast2SMS\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\"},\"email\":\"support@fast2sms.com\",\"telephone\":\"+91-6262778822\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Fast2SMS\",\"https:\\\/\\\/www.instagram.com\\\/fast2sms\",\"https:\\\/\\\/x.com\\\/fast2sms\",\"https:\\\/\\\/www.youtube.com\\\/Fast2SMSofficial\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/fast2sms\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Node.js Express OTP Verification Widget | Fast2SMS","description":"Add Node.js OTP verification to your Express app: a ready \/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.","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:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/","og_locale":"en_US","og_type":"article","og_title":"Node.js Express OTP Verification Widget | Fast2SMS","og_description":"Add Node.js OTP verification to your Express app: a ready \/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.","og_url":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/","og_site_name":"Fast2SMS","article_publisher":"https:\/\/www.facebook.com\/Fast2SMS\/","article_published_time":"2026-11-18T19:58:50+00:00","article_modified_time":"2026-11-18T20:34:46+00:00","og_image":[{"width":2560,"height":1600,"url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_creator":"@fast2sms","twitter_site":"@fast2sms","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#article","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/"},"author":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"headline":"Node.js Express OTP verification with the Fast2SMS OTP widget","datePublished":"2026-11-18T19:58:50+00:00","dateModified":"2026-11-18T20:34:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/"},"wordCount":1382,"publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp","articleSection":["API","OTP"],"inLanguage":"en-IN"},{"@type":"WebPage","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/","url":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/","name":"Node.js Express OTP Verification Widget | Fast2SMS","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#primaryimage"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp","datePublished":"2026-11-18T19:58:50+00:00","dateModified":"2026-11-18T20:34:46+00:00","description":"Add Node.js OTP verification to your Express app: a ready \/f2s-otp endpoint, a drop-in widget and signed tokens. SMS and WhatsApp with Fast2SMS.","breadcrumb":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#breadcrumb"},"inLanguage":"en-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/"]}]},{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#primaryimage","url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp","contentUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-31-scaled.webp","width":2560,"height":1600,"caption":"Smart OTP Template page with WhatsApp and SMS OTP template cards, each showing its OTP ID, sender or number, template ID and fallback"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-nodejs-express-fast2sms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fast2sms.com\/help\/"},{"@type":"ListItem","position":2,"name":"API","item":"https:\/\/www.fast2sms.com\/help\/api\/"},{"@type":"ListItem","position":3,"name":"Node.js Express OTP verification with the Fast2SMS OTP widget"}]},{"@type":"WebSite","@id":"https:\/\/www.fast2sms.com\/help\/#website","url":"https:\/\/www.fast2sms.com\/help\/","name":"Fast2SMS","description":"Help","publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"inLanguage":"en-IN"},{"@type":"Organization","@id":"https:\/\/www.fast2sms.com\/#organization","name":"Fast2SMS","url":"https:\/\/www.fast2sms.com\/","logo":{"@type":"ImageObject","@id":"https:\/\/www.fast2sms.com\/#logo","url":"https:\/\/www.fast2sms.com\/Fast2SMS.png","contentUrl":"https:\/\/www.fast2sms.com\/Fast2SMS.png","caption":"Fast2SMS"},"image":{"@id":"https:\/\/www.fast2sms.com\/#logo"},"email":"support@fast2sms.com","telephone":"+91-6262778822","sameAs":["https:\/\/www.facebook.com\/Fast2SMS","https:\/\/www.instagram.com\/fast2sms","https:\/\/x.com\/fast2sms","https:\/\/www.youtube.com\/Fast2SMSofficial","https:\/\/www.linkedin.com\/company\/fast2sms"]}]}},"_links":{"self":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/19663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/comments?post=19663"}],"version-history":[{"count":1,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/19663\/revisions"}],"predecessor-version":[{"id":20040,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/19663\/revisions\/20040"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media\/19646"}],"wp:attachment":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media?parent=19663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/categories?post=19663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/tags?post=19663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}