비트베이크

Implementing Serverless SMS Authentication with Astro Actions in 5 Minutes (Zero Paperwork)

2026-06-02T01:02:54.699Z

ASTRO-ACTIONS-SMS

Why is adding SMS Authentication to a side project so painful?

Have you ever tried to add SMS-based identity verification to your toy project or startup MVP? The moment you start integrating an API, you are met with a mountain of bureaucratic requirements: business registration documents, proof of telecommunication service usage, and mandatory caller ID pre-registration. For solo developers or early-stage MVPs trying to validate a hypothesis quickly, these hurdles make it almost impossible to even begin.

Moreover, if you are building a frontend-centric project using Astro, spinning up a dedicated backend server (Node.js, Spring, etc.) just to handle a single SMS authentication endpoint feels like massive overkill.

Today, we'll explore how to implement a serverless SMS authentication flow using Astro Actions and frontend code only. We will be using EasyAuth, a developer-friendly SMS API that requires zero paperwork and can be set up in under 5 minutes.


The Solution: Astro Actions + EasyAuth

  1. Astro Actions: Introduced in Astro 4.15, Actions provide a way to define type-safe backend functions (RPCs) that can be called directly from your client-side code. This means you can write server-side logic without setting up a separate API route or backend framework.
  2. EasyAuth: The ultra-simple SMS API designed for developers.
    • Zero Paperwork: Start immediately with just an email—no business documents required.
    • Instant Setup: API integration takes under 5 minutes (automatic caller ID provided).
    • 💰 Affordable Pricing: 15~25 KRW per message (up to 50% cheaper than traditional providers).
    • 🎁 Free Trial: Get 10 free test credits instantly upon sign-up.

Step 1: Project Setup and API Key Generation

First, sign up on the EasyAuth website to get your API Key. Because there are no document reviews or caller ID registration processes, you can find your EASYAUTH_API_KEY in your dashboard immediately after signing up.

Create a .env file at the root of your Astro project and add your generated key:

EASYAUTH_API_KEY=your_api_key_here

Step 2: Defining the Astro Action (Server Logic)

Create a file at src/actions/index.ts. We will define two actions: sendSms for dispatching the OTP (One-Time Password) and verifySms for checking it. EasyAuth only consists of two simple endpoints (POST /send and POST /verify), making integration highly intuitive.

// src/actions/index.ts
import { defineAction } from 'astro:actions';
import { z } from 'astro:schema';

export const server = {
  sendSms: defineAction({
    accept: 'json',
    input: z.object({
      phone: z.string().regex(/^010\d{8}$/, 'Please enter a valid mobile number.'),
    }),
    handler: async (input) => {
      const res = await fetch('https://api.easyauth.co.kr/send', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${import.meta.env.EASYAUTH_API_KEY}`
        },
        body: JSON.stringify({ to: input.phone })
      });
      
      if (!res.ok) {
        const errorData = await res.json();
        throw new Error(errorData.message || 'Failed to send verification code.');
      }
      return { success: true };
    }
  }),

  verifySms: defineAction({
    accept: 'json',
    input: z.object({
      phone: z.string(),
      code: z.string().length(6, 'Verification code must be 6 digits.')
    }),
    handler: async (input) => {
      const res = await fetch('https://api.easyauth.co.kr/verify', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${import.meta.env.EASYAUTH_API_KEY}`
        },
        body: JSON.stringify({ to: input.phone, code: input.code })
      });
      
      if (!res.ok) {
        const errorData = await res.json();
        throw new Error(errorData.message || 'Invalid verification code.');
      }
      return { success: true };
    }
  })
};

Tip: Using zod from astro:schema ensures that data coming from the client (like phone number format and code length) is safely validated on the server side.

Step 3: Calling Actions from the Client

Now, let's create the user interface and call the Actions we just created using Vanilla JavaScript.

---
// src/pages/index.astro
import Layout from '../layouts/Layout.astro';
---


  <main>
    <h1>Mobile Verification</h1>
    
    <div>
      
      <div>
        Phone Number
        <div>
          
          Send
        </div>
      </div>

      
      <div>
        6-Digit Code
        <div>
          
          Verify
        </div>
      </div>
    </div>
  </main>

  

Tips & Best Practices for Production

  1. Security Considerations (Rate Limiting) In a production environment, you must prevent malicious users from abusing your SMS endpoints and racking up charges. It is highly recommended to implement rate limiting via Astro middleware or utilize a CAPTCHA solution like Cloudflare Turnstile to block automated bot requests.

  2. Protecting Environment Variables The EASYAUTH_API_KEY is only meant to be used inside src/actions/index.ts, which runs server-side. Never expose this key to your frontend clients by prefixing it with PUBLIC_!

Conclusion

By combining Astro Actions with EasyAuth, we've built a clean, fully functional SMS authentication system in just 5 minutes—without spinning up a backend server or filling out tedious paperwork.

  • Infrastructure overhead? ➡️ Solved by Astro Actions
  • Complex documents & high fees? ➡️ Solved by EasyAuth

If you're a solo developer or currently building a side project, you can get started right away without any paperwork. Sign up for EasyAuth today and claim your 10 free test credits. Launching your service MVP just got a whole lot easier!

비트베이크에서 광고를 시작해보세요

광고 문의하기

다른 글 보기

2026-06-16T11:01:56.081Z

다이소 여름 꿀템 싹쓰리! 워터프루프 & 쿨링 뷰티템 추천

2026년 여름, 뜨거운 태양과 습기 속에서도 완벽한 뷰티를 유지하고 싶다면 다이소 여름 꿀템에 주목하세요! 워터프루프 메이크업부터 쿨링 스킨케어, 휴대성 좋은 여행용 뷰티템까지, 합리적인 가격으로 나만의 인생템을 찾아 빛나는 여름 뷰티 루틴을 완성할 수 있습니다.

2026-06-16T11:01:44.306Z

2026 간헐적 단식 성공 비법: 식단 & 홈트 병행 체중 감량 팁

2026년 최신 트렌드를 반영한 간헐적 단식 성공 비법을 공개합니다. 식단 가이드, 홈트레이닝 루틴, 부작용 최소화 팁까지 지속 가능한 체중 감량을 위한 모든 정보를 확인하세요.

2026-06-16T11:01:41.128Z

2026 GLP-1 작용제: 비만, 당뇨 넘어 '건강 수명' 시대 여나?

GLP-1 작용제가 비만과 당뇨를 넘어 심혈관 및 신장 보호 효과까지 입증하며 '건강 수명' 연장의 핵심 열쇠로 주목받고 있습니다. 2026년을 앞두고 더욱 다양해질 GLP-1 신약의 최신 트렌드와 현명한 활용법을 의학 전문가의 시선으로 살펴봅니다.

2026-06-16T11:01:21.401Z

2026년 ISA·연금저축 세액공제 200% 활용: 노후준비 끝판왕

2026년에도 ISA와 연금저축, IRP는 강력한 절세 도구입니다. 최신 세법 동향을 반영한 이 글에서 ISA의 비과세/분리과세 전략, 연금저축과 IRP의 세액공제 혜택, 그리고 ISA 만기 자금을 연금 계좌로 이전하여 세액공제를 200% 만드는 꿀팁까지, 여러분의 노후준비를 위한 실질적인 재테크 전략을 공개합니다.

서비스

피드자주 묻는 질문고객센터

문의

비트베이크

레임스튜디오 | 사업자 등록번호 : 542-40-01042

경기도 남양주시 와부읍 수례로 116번길 16, 4층 402-제이270호

트위터인스타그램네이버 블로그