Skip to content

ShenSeanChen/launch-kit-stripe-nextjs-supabase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

577d894 Β· Mar 5, 2025

History

14 Commits
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Mar 5, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025
Feb 27, 2025

Repository files navigation

Next.js + Stripe + Supabase Production-Ready Template

A production-ready Next.js template featuring authentication, dark mode support, Stripe integration, and a clean, modern UI. Built with TypeScript and Tailwind CSS.

License Next.js TypeScript Tailwind

πŸ“Ή Full Video Guide: youtube link β˜•οΈ Buy me a coffee: Cafe Latte

✨ Features

  • πŸ” Authentication with Supabase
  • πŸ’³ Stripe payment integration
  • πŸŒ“ Dark mode support
  • πŸ“± Responsive design
  • 🎨 Tailwind CSS styling
  • πŸ”„ Framer Motion animations
  • πŸ›‘οΈ TypeScript support
  • πŸ“Š Error boundary implementation
  • πŸ” SEO optimized

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • A Supabase account
  • A Stripe account
  • A Google Cloud Platform account

Installation and Setup

  1. Clone the template:
git clone https://github.com/ShenSeanChen/launch-stripe-nextjs-supabase my-full-stack-app
cd my-full-stack-app
rm -rf .git
git init
git add .
git commit -m "Initial commit"
# git remote add origin https://github.com/ShenSeanChen/my-full-stack-app.git
git remote add origin https://github.com/USE_YOUR_OWN_GITHUB_NAME/my-full-stack-app.git
git push -u origin main
  1. Install dependencies:
npm install

or

yarn install
  1. Create .env.local with all variables from .env.example
NEXT_PUBLIC_APP_URL=http://localhost:8000
NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_WS_URL=ws://localhost:8080

# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=

# OpenAI Configuration (you'll need to add your key)
OPENAI_API_KEY=

# Stripe Configuration
# NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_
NEXT_PUBLIC_STRIPE_BUTTON_ID=buy_btn_
# STRIPE_SECRET_KEY=sk_test_
STRIPE_SECRET_KEY=sk_live_
# STRIPE_WEBHOOK_SECRET=whsec_
STRIPE_WEBHOOK_SECRET=whsec_

# ANALYTICS
NEXT_PUBLIC_POSTHOG_KEY=
NEXT_PUBLIC_POSTHOG_HOST=https://app.posthog.com
  1. Set up Google Cloud Platform (GCP):

    • Create new OAuth 2.0 credentials in GCP Console
    • Configure authorized JavaScript origins
    • Configure redirect URIs
    • Save the Client ID and Client Secret
  2. Configure Supabase:

    a. Get API Keys (Project Settings > API):

    • Project URL β†’ NEXT_PUBLIC_SUPABASE_URL
    • Anon Public Key β†’ NEXT_PUBLIC_SUPABASE_ANON_KEY
    • Service Role Secret β†’ SUPABASE_SERVICE_ROLE_KEY

    b. Set up Authentication:

    • Go to Authentication > Providers > Google
    • Add your GCP Client ID and Client Secret
    • Update Site URL and Redirect URLs

    c. Database Setup:

    • Enable Row Level Security (RLS) for all tables
    • Create policies for authenticated users and service roles
    • Create the following trigger function:
    CREATE OR REPLACE FUNCTION public.handle_new_user()
    RETURNS trigger AS $$
    BEGIN
      INSERT INTO public.users (id, email, created_at, updated_at, is_deleted)
      VALUES (NEW.id, NEW.email, NOW(), NOW(), FALSE);
      
      INSERT INTO public.user_preferences (user_id, has_completed_onboarding)
      VALUES (NEW.id, FALSE);
      
      INSERT INTO public.user_trials (user_id, trial_start_time, trial_end_time)
      VALUES (NEW.id, NOW(), NOW() + INTERVAL '48 hours');
      
      RETURN NEW;
    END;
    $$ LANGUAGE plpgsql SECURITY DEFINER;
    
    CREATE TRIGGER on_auth_user_created
      AFTER INSERT ON auth.users
      FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
  3. Set up Stripe:

    a. Create a live account and configure:

    • Create product in Product Catalog
    • Create promotional coupon codes
    • Set up Payment Link with trial period

    b. Get required keys:

    • Publishable Key β†’ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
    • Secret Key β†’ STRIPE_SECRET_KEY
    • Buy Button ID β†’ NEXT_PUBLIC_STRIPE_BUTTON_ID

    c. Configure webhooks:

    • Add endpoint: your_url/api/stripe/webhook
    • Subscribe to events: customer.subscription., checkout.session., invoice., payment_intent.
    • Copy Signing Secret β†’ STRIPE_WEBHOOK_SECRET
  4. Start the development server:

npm run dev

or

yarn dev
  1. Open http://localhost:3000 in your browser.

πŸ“– Project Structure

β”œβ”€β”€ app/                  # Next.js 14 app directory
β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”œβ”€β”€ stripe/       # Stripe payment endpoints
β”‚   β”‚   └── user/         # User API endpoints
β”‚   β”œβ”€β”€ auth/             # Auth-related pages
β”‚   β”‚   β”œβ”€β”€ callback/     # handle auth callback
β”‚   β”œβ”€β”€ dashboard/        # Dashboard pages
β”‚   β”œβ”€β”€ pay/              # Payment pages
β”‚   β”œβ”€β”€ profile/          # User profile pages
β”‚   β”œβ”€β”€ reset-password/   # Reset password pages
β”‚   β”œβ”€β”€ update-password/  # Update password pages
β”‚   β”œβ”€β”€ verify-email/     # Verify email pages
β”‚   β”œβ”€β”€ layout.tsx        # Root layout
β”‚   └── page.tsx          # Home page
β”œβ”€β”€ components/           # Reusable components
β”œβ”€β”€ contexts/             # React contexts
β”œβ”€β”€ hooks/                # Custom React hooks
β”œβ”€β”€ utils/                # Utility functions
β”œβ”€β”€ types/                # TypeScript type definitions
β”œβ”€β”€ public/               # Static assets
└── styles/               # Global styles

πŸ› οΈ Built With

πŸ”§ Configuration

Tailwind Configuration

The template includes a custom Tailwind configuration with:

  • Custom colors
  • Dark mode support
  • Extended theme options
  • Custom animations

Authentication

Authentication is handled through Supabase with support for:

  • Email/Password
  • Google OAuth
  • Magic Links
  • Password Reset

Payment Integration

Stripe integration includes:

  • Subscription management
  • Trial periods
  • Webhook handling
  • Payment status tracking

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Vercel for the deployment platform
  • Tailwind CSS team for the utility-first CSS framework
  • Supabase team for the backend platform
  • Stripe team for the payment infrastructure

πŸ“« Contact

X - @ShenSeanChen

YouTube - @SeanTechStories

Discord - @Sean's Stories

Instagram - @SeanTechStories

Project Link: https://github.com/ShenSeanChen/launch-stripe-nextjs-supabase

πŸš€ Deploy

The easiest way to deploy your Next.js app is to use the Vercel Platform.

Deploy with Vercel


Made with πŸ”₯ by ShenSeanChen

About

Welcome to Sean's Open Source Template for Production-Ready NextJS+Stripe+Supabase App.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages