npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

osdev-auth-supabase-with-username

v1.0.0

Published

Complete Next.js authentication template with Supabase including custom username support for all auth providers (email, OAuth). Production-ready starter kit.

Readme

osdev-auth-supabase-with-username

npm version License: MIT

Complete Next.js authentication template with Supabase including custom username support for all auth providers.

A production-ready Next.js 14+ authentication template powered by Supabase with built-in username support for all authentication providers (email, OAuth, etc.).

✨ Features

  • Custom Username System - Works with email and OAuth signups
  • Automatic Profile Creation - Smart defaults for missing user data
  • Unique Username Generation - Automatic conflict resolution
  • All Auth Providers - Google, GitHub, and more
  • Complete Auth Flows - Signup, login, password reset, email confirmation
  • Modern UI - shadcn/ui components with dark/light theme
  • TypeScript - Fully typed for better DX
  • RLS Configured - Row Level Security ready
  • Public Usernames - Perfect for @mentions and profiles

🚀 Quick Start

Using npx (Recommended)

npx osdev-auth-supabase-with-username my-app
cd my-app
npm install

Manual Installation

# Clone the repository
git clone https://github.com/omransoliman97/nextjs-supabase-auth-osdev-with-username.git my-app
cd my-app

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your Supabase credentials

# Run development server
npm run dev

📦 What's Included

Dependencies

All required dependencies will be installed:

  • @supabase/supabase-js & @supabase/ssr - Supabase client
  • shadcn/ui components - Alert, Button, Card, Input, Label, Sonner
  • react-icons - Icon library
  • next-themes - Dark/Light theme support
  • tw-animate-css - Animation utilities
  • TypeScript configuration

Project Structure

├── app/
│   ├── (auth)/
│   │   ├── login/              # Login page
│   │   ├── signup/             # Signup with username
│   │   ├── forgot-password/    # Password reset request
│   │   ├── reset-password/     # Update password
│   │   └── auth/
│   │       ├── callback/       # OAuth callback
│   │       ├── confirm/        # Email confirmation
│   │       └── confirmed/      # Success page
│   ├── error/                  # Error page
│   └── not-found/              # 404 page
├── components/
│   ├── LoginForm.tsx
│   ├── SignupForm.tsx
│   ├── RequestResetForm.tsx
│   ├── UpdatePasswordForm.tsx
│   ├── ProvidersButtons.tsx
│   └── ThemeToggle.tsx
├── lib/
│   ├── auth-functions.ts       # All auth operations
│   ├── auth-utils.ts           # Server-side utilities
│   └── auth-utils-client.ts    # Client-side utilities
├── hooks/
│   └── useAuthRedirectClient.ts # Client-side protection
├── utils/supabase/
│   ├── client.ts
│   ├── server.ts
│   └── middleware.ts
└── IMPORTANT/
    ├── INSTRUCTIONS.md         # Complete setup guide
    ├── DatabaseProfilesHandler.md
    ├── EmailConfirmSignUp.md
    ├── EmailResetPassword.md
    └── PublicCanViewUsername.md

🔧 Setup Requirements

Prerequisites

  • Node.js 18.0 or higher
  • Supabase account (Sign up here)
  • Basic knowledge of Next.js and React

Environment Variables

NEXT_PUBLIC_BASE_URL=your-url
NEXT_PUBLIC_SUPABASE_URL=your-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

Database Setup

The template includes SQL scripts for:

  1. Creating the profiles table
  2. handle_new_user function (auto-creates profiles)
  3. Database trigger (runs on user signup)
  4. RLS policies (public username access)

📖 See IMPORTANT/INSTRUCTIONS.md for complete setup guide.

🎯 How It Works

Username System

When a user signs up, data is stored in raw_user_meta_data:

{
  first_name: "Omran",
  last_name: "Soliman",
  username: "omransoliman"
}

The handle_new_user function automatically:

  • Creates a profile with first_name, last_name, and username
  • Applies smart defaults for missing data
  • Generates unique usernames (e.g., omransolimanomransoliman79 if duplicate)
  • Works with ALL auth providers (email, Google, GitHub, etc.)

Public Usernames

Usernames are publicly accessible through RLS policies, perfect for:

  • @mentions in social features
  • Public user profiles
  • User discovery
  • Leaderboards and rankings

📚 Documentation

Comprehensive documentation included:

  • INSTRUCTIONS.md - Complete setup guide with troubleshooting
  • Database scripts - Ready-to-use SQL for Supabase
  • Email templates - Customizable confirmation and reset emails
  • Code comments - Every file is well-documented

🛠️ Commands

# Development
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Lint code
npm run lint

🌐 Deploy

Vercel (Recommended)

  1. Push your code to GitHub
  2. Import to Vercel
  3. Add environment variables
  4. Deploy

📖 Next.js Deployment Docs

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT © Omran Soliman

🔗 Links

⭐ Support

If this template helped you, please give it a star on GitHub!


Perfect for: SaaS applications, social platforms, community sites, or any project requiring usernames with authentication.