Skip to content

kstonekuan/email-waiting-list

Repository files navigation

Cloudflare Waiting List Worker

A simple Cloudflare Worker to handle email signups for a waiting list.

Setup

  1. Install dependencies:

    pnpm install
  2. Copy the example config:

    cp wrangler.toml.example wrangler.toml
  3. Create a KV namespace:

    wrangler kv namespace create "<YOUR_KV_NAME>"
    wrangler kv namespace create "<YOUR_KV_NAME>" --preview
  4. Update wrangler.toml with your KV namespace IDs from the output above.

  5. Deploy:

    pnpm deploy

API Endpoints

POST /signup

Add an email to the waitlist.

Request:

{
  "email": "user@example.com"
}

Response:

{
  "success": true,
  "message": "Successfully added to waitlist"
}

Development

Run locally:

pnpm dev

Frontend Integration

<form id="waitlist-form">
  <input type="email" id="email" required>
  <button type="submit">Join Waitlist</button>
</form>

<script>
document.getElementById('waitlist-form').addEventListener('submit', async (e) => {
  e.preventDefault();
  
  const email = document.getElementById('email').value;
  
  const response = await fetch('https://your-worker.workers.dev/signup', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email }),
  });
  
  const data = await response.json();
  alert(data.message);
});
</script>

About

Cloudflare worker for an email waiting list sign up

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published