CareTiger / nuxt3-saas-boilerplate

https://saas-boilerplate-kappa.vercel.app
6 stars 0 forks source link

Nuxt 3 (SAAS) Boilerplate

Not Production Ready

Please don't hitch your wagon to this star just yet...

Tech Stack

Features

User Management

Schema and DB Management

Config Management and Env integration

Multi-Modal State Management (route rules)

Blog

Tailwind CSS & Icons & Fonts & Forms (UnoCSS is the future)

Modals and toasts

Plans and Pricing

Stripe (Payments) Integration

A/B testing and analytics

Support

Look and Feel, Design System and Customisation

Demo Software (Notes)

Mobile App

Testing

Externals Setup

Things you gotta do that aren't code (and are therefore not very interesting)

Env

Copy the .env_example file to create .env Note) This file is for development convenience, is .gitignored by default and should not be added to source control

Supabase

This solution uses Supabase for Auth and to provide a DB. In addition to Magic Link and email/password login via Supabase, it also supports Google OAuth via Supabase.

  1. Go to Supabase and 'Start your Project'
  2. Setup your org and project (Free tier is fine to start)
  3. Update the project's email template
  4. Choose an OAuth provider. I have chosen Google using these Instructions for the purposes of demonstration but they all should work.
  5. Go to Project Settings -> API and copy Project URL and Project API Key to SUPABASE_URL and SUPABASE_KEY settings respectively in your .env file
  6. Go to Project Settings -> Database -> Connection String -> URI and copy the uri value into the DATABASE_URL setting in your .env file, remembering to replace [YOUR-PASSWORD] with the password you provided when you setup the project.

Stripe

This solution uses Stripe for Subscription payments.

  1. Go to Stripe and setup your business (Free Tier is fine to start)
  2. Create 3 products ('Community plan', 'Basic Plan' and 'Premium Plan') each with a single price and note the Product ID's and Price ID's
  3. Edit the seed.ts file and replace the stripe_product_id values with the Product ID's)
    create: {
      name: 'Team Plan',
      .....
      stripe_product_id: '[Your Product ID from Stripe]'
    },
  1. Edit the Pricing pricing page and put your Price ID's from 2) into the appropriate hidden price_id form fields...
<input type="hidden" name="price_id" value="[Your Price ID from Stripe]" />

Setup Database (Prisma)

This solution uses Prisma to both manage changes and connect to the Postgresql database provided by Supabase. Your Supabase DB will be empty by default so you need to hydrate the schema and re-generate the local prisma client.

npx prisma db push
npx prisma generate
npm install @prisma/client --save-dev
npx prisma db seed

...you should now have a a Plan table with 3 rows and a bunch of empty tables in your Supabase DB

Developement Setup

Dependencies

# yarn
yarn install

# npm
npm install

# pnpm
pnpm install --shamefully-hoist

Webhook Forwarding

This makes sure that you can debug subscription workflows locally

stripe listen --forward-to localhost:3000/webhook

Start the development server on http://localhost:3000

npm run dev

Production

Build the application for production:

npm run build

Locally preview production build:

npm run preview

Check out the deployment documentation for more information.