ReSMS Logo
Skip to Content
QuickstartNode.js

Node.js

Welcome to the ReSMS Node.js integration guide.

This guide explains how you can quickly and securely send SMS messages using the ReSMS API in your Node.js applications.

Installation

First, install our official ReSMS Node.js SDK:

npm install @resms/sdk # or bun add @resms/sdk # or yarn add @resms/sdk

Setup

You need to get an API key on ReSMS Dashboard. Then import the package and create a new instance of the ReSMS class with your API key.

import { ReSMS } from "@resms/sdk"; const resms = new ReSMS("re_12345");

Quickstart

Here’s a minimal example to send an SMS:

import { ReSMS } from "@resms/sdk"; const resms = new ReSMS("re_12345"); await resms.send({ to: "+33123456789", message: "Your sign-in code is 123456", });

Environment Variables

To keep it secure, we recommend using environment variables to store your API key.

RESMS_API_KEY=your-api-key-here

Then, in your code, you can access it like this:

const resms = new ReSMS(process.env.RESMS_API_KEY);

Error Handling

All API calls can throw errors. We recommend wrapping your SMS calls with try-catch:

try { const response = await resms.send({ to: "+33123456789", message: "Your sign-in code is 123456", }); console.log('SMS sent successfully:', response); } catch (error) { console.error('Failed to send SMS:', error); }

Going Further


Need help? Contact our support at contact@resms.dev

Last updated on