λͺ©. 8μ›” 14th, 2025

D: Supabase is an open-source Firebase alternative that provides a PostgreSQL database, authentication, real-time subscriptions, and storage. 🌟 In this guide, we’ll walk through setting up a basic login system using Supabase in just 5 minutes!


πŸ”§ Prerequisites

Before we begin, make sure you have:

  • A Supabase account (sign up here)
  • Basic knowledge of JavaScript (or any frontend framework)
  • A simple HTML file (or a React/Vue/Svelte project)

πŸ›  Step 1: Create a Supabase Project

  1. Go to Supabase Dashboard and click New Project.
  2. Enter a Project Name and set a Database Password.
  3. Choose a Region closest to your users for better performance.
  4. Click Create Project (it may take a minute to initialize).

βœ… Done! Your Supabase project is ready.


πŸ”‘ Step 2: Enable Authentication

Supabase provides built-in auth providers (Email, Google, GitHub, etc.).

  1. In your project dashboard, go to Authentication β†’ Providers.
  2. Enable Email/Password (for a simple login system).
  3. (Optional) Enable Google/GitHub for OAuth login.

πŸ“Œ Pro Tip: Under Authentication β†’ Settings, customize your Site URL (e.g., http://localhost:3000 for local testing).


πŸ’» Step 3: Set Up Frontend (HTML + JavaScript Example)

Let’s create a simple login form.

HTML (index.html)

<!DOCTYPE html>
<html>
<head>

<title>Supabase Login</title>
  <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
</head>
<body>

<div>

<h2>Login</h2>
    <input type="email" id="email" placeholder="Email" />
    <input type="password" id="password" placeholder="Password" />
    <button onclick="signIn()">Sign In</button>
    <button onclick="signUp()">Sign Up</button>
    <button onclick="signOut()">Sign Out</button>
  </div>
  <script src="app.js"></script>
</body>
</html>

JavaScript (app.js)

const SUPABASE_URL = 'YOUR_SUPABASE_URL';
const SUPABASE_KEY = 'YOUR_SUPABASE_ANON_KEY';

const supabase = supabase.createClient(SUPABASE_URL, SUPABASE_KEY);

async function signUp() {
  const email = document.getElementById('email').value;
  const password = document.getElementById('password').value;

  const { data, error } = await supabase.auth.signUp({
    email,
    password,
  });

  if (error) alert(error.message);
  else alert('Check your email for confirmation!');
}

async function signIn() {
  const email = document.getElementById('email').value;
  const password = document.getElementById('password').value;

  const { data, error } = await supabase.auth.signInWithPassword({
    email,
    password,
  });

  if (error) alert(error.message);
  else alert('Logged in successfully!');
}

async function signOut() {
  const { error } = await supabase.auth.signOut();
  if (error) alert(error.message);
  else alert('Logged out!');
}

πŸ” Where to find SUPABASE_URL and SUPABASE_KEY?

  • Go to Project Settings β†’ API in your Supabase dashboard.

πŸš€ Step 4: Test Your Login System

  1. Open index.html in a browser.
  2. Sign Up with an email & password.
  3. Sign In with the same credentials.
  4. Sign Out to test logout.

πŸŽ‰ Congratulations! You’ve built a working auth system in 5 minutes!


πŸ“Œ Bonus Tips

βœ” Secure Your App: Use Row-Level Security (RLS) in Supabase to restrict database access.
βœ” Add Social Logins: Enable Google/GitHub in Authentication β†’ Providers.
βœ” Go Beyond: Try Supabase’s Realtime and Storage features!


πŸ”— Next Steps

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

λ‹΅κΈ€ 남기기

이메일 μ£Όμ†ŒλŠ” κ³΅κ°œλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. ν•„μˆ˜ ν•„λ“œλŠ” *둜 ν‘œμ‹œλ©λ‹ˆλ‹€