ReSMS Logo
Skip to Content
QuickstartNext.js

Next.js

Welcome to the ReSMS Next.js integration guide.

This guide explains how to integrate ReSMS easily in your Next.js application to send SMS notifications to your users.

Installation

First, install the ReSMS SDK:

npm install resms-sdk # or yarn add resms-sdk # or bun add resms-sdk

Usage Example

Here’s how you can send an SMS in an API Route (/app/api/send-sms/route.ts):

import { NextResponse } from 'next/server'; import { ReSMSClient } from 'resms-sdk'; const client = new ReSMSClient({ apiKey: process.env.RESMS_API_KEY, }); export async function POST(request: Request) { try { const { to, message } = await request.json(); const response = await client.sendSMS({ to, message }); return NextResponse.json({ success: true, response }); } catch (error) { return NextResponse.json({ success: false, error: String(error) }, { status: 500 }); } }

Environment Variables

Set your ReSMS API key securely in your .env.local:

RESMS_API_KEY=your-api-key-here

Never expose your API key in client-side code.

Features

  • Use ReSMS in Next.js Server Actions
  • Send SMS inside API Routes (route handlers)
  • High security: Only server-side

Recommendations

  • Always validate input data before sending SMS
  • Monitor your SMS sending metrics through the ReSMS Dashboard
  • Rotate API keys periodically for enhanced security

Need help? Reach out to support@resms.io

Last updated on