Click here for all the docs.
- Node.js (v20 or later)
- pnpm (v9)
- A Postgres database provider (we recommend Supabase or Vercel Postgres)
- A Stripe account
- A Resend account (used for newsletter, and email sign-in / sign-up)
- Posthog (for analytics)
- Sentry (for error handling)
- Google Cloud Account (for Google OAuth)
- Clone the repository:
git clone https://github.com/collinschaafsma/startstack.git
cd startstack
- Install dependencies:
pnpm install
Create a .env
file in the root of your project you can use the .env.example
file to get started:
cp .env.example .env
- Sign up for a Supabase account and create a new project.
- Click the
Connect
button to view your connection string. - Update the connection string in your
.env
file.
POSTGRES_URL="<your-connection-string>?workaround=supabase-pooler.vercel"
Note: Notice how the connection string has a
?workaround=supabase-pooler.vercel
at the end. This is required when deploying to Vercel. See docs. Don't forget to add your password to the connection string.
Alternatively you can use the Vercel Supabase integration to setup your database.
- Create a new Postgres database in Vercel Storage. A
POSTGRES_URL
env will be set in your project. - Update the connection string in your
.env
file.
POSTGRES_URL="<your-connection-string>"
Note: We recommend having a dedicated database for development and another for production. This allows you to make changes to the database schema without affecting the production database while developing locally. Or better yet, checkout Supabase database branching for your vercel preview deployments!
pnpm run db:migrate
Note: This will create the tables in your database.
Once you have a database setup and the migrations have been run, you can start the development server:
pnpm dev
Open your browser and navigate to http://localhost:3000
.
openssl rand -base64 32
Update the AUTH_SECRET
in your .env
file.
AUTH_SECRET="YOUR-SECRET-KEY"
Note: Make sure you generate different keys for all of your environments!
- Sign up for a Resend.
- Make sure you have properly setup your domain and verified it.
- Create a API key in your Resend dashboard.
- Update the
RESEND_API_KEY
in your.env
file.
RESEND_API_KEY="YOUR-API-KEY"
- Update the
AUTH_EMAIL_FROM
in your.env
file.
AUTH_EMAIL_FROM="Acme <[email protected]>"
- Navigate to http://localhost:3000/sign-up and you should see the email provider option. Go ahead and sign up. You should receive an email with a sign in link.
Note: Full documentation on setting up resend can be found here.
- See: Using OAuth 2.0 to Access Google APIs
- See: Configuring a client app
- Update the
AUTH_GOOGLE_ID
andAUTH_GOOGLE_SECRET
in your.env
file.
AUTH_GOOGLE_ID="YOUR-CLIENT-ID"
AUTH_GOOGLE_SECRET="YOUR-CLIENT-SECRET"
- Navigate to http://localhost:3000/sign-up and you should see an option to login with Google.
Note: Full documentation on setting up Google OAuth can be found here.
pnpm grant:admin:role [email protected]
Note: This will grant the user the admin role in the database based on your local
POSTGRES_URL
env var. You can also edit the user table in the database directly using the Supabase Table Editor or any other db editor like Postico etc.
- Sign up for a Stripe account.
- Note your publishable key and secret key from your Stripe dashboard.
- Update the
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
andSTRIPE_SECRET_KEY
in your.env
file.
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="YOUR-PUBLISHABLE-KEY"
STRIPE_SECRET_KEY="YOUR-SECRET-KEY"
Note: Make sure you set your production keys in Vercel based on the live Stripe environment.
- Authenticate the Stripe CLI with your Stripe account, if you have multiple projects make sure you select the correct one:
pnpm stripe:login
- Start the dev server
pnpm dev
Note: Make sure you don't have the coming soon page enabled locally in your
.env
file.
NEXT_PUBLIC_ENABLE_COMING_SOON="false"
- Listen for webhooks
pnpm stripe:listen
- Note the webhook secret returned by the CLI and update the
STRIPE_WEBHOOK_SECRET
in your.env
file.
STRIPE_WEBHOOK_SECRET="YOUR-WEBHOOK-SECRET"
- Create a new product & price in your Stripe dashboard. You should see your product on the home page. You can also verify your data in your database. Use the Supabase Table Editor or run the following command to connect to your database using drizzle studio:
pnpm db:studio
Note: You must agree to Stripe's terms of service if you have enabled consent_collection (default) here.
- Login to Resend and navigate to your account.
- Click on
Audiences
and create a new audience. - Copy the audience id and update the
RESEND_NEWSLETTER_AUDIENCE_ID
in your.env
file.
RESEND_NEWSLETTER_AUDIENCE_ID="YOUR-AUDIENCE-ID"
- Sign up for a PostHog account.
- Create a new project and click on
Settings
. - You will see a code snippet that looks like this:
<script>
... omitted ...
posthog.init('<YOUR-POSTHOG-KEY>',{api_host:'<YOUR-POSTHOG-HOST>', person_profiles: 'identified_only')
</script>
- Update the
NEXT_PUBLIC_POSTHOG_KEY
,NEXT_PUBLIC_POSTHOG_HOST
in your.env
file.
NEXT_PUBLIC_POSTHOG_KEY="<YOUR-POSTHOG-KEY>"
NEXT_PUBLIC_POSTHOG_HOST="<YOUR-POSTHOG-HOST>"
- Sign up for a Sentry account.
- Click on
Settings
. Note theOrganization Slug
. - Update the
SENTRY_ORG
in your.env
file.
SENTRY_ORG="<YOUR-ORGANIZATION-SLUG>"
- Create a new project and note the
Project Name
. - Update the
SENTRY_PROJECT
in your.env
file.
SENTRY_PROJECT="<YOUR-PROJECT-NAME>"
- Create a new auth token. Click
Settings
->Auth Tokens
->Create Auth Token
. - Update the
SENTRY_AUTH_TOKEN
in your.env
file.
SENTRY_AUTH_TOKEN="<YOUR-AUTH-TOKEN>"
- Create a new client key. Click
Settings
->Client Keys
copy the DSN orGenerate New Key
. - Update the
NEXT_PUBLIC_SENTRY_DSN
in your.env
file.
NEXT_PUBLIC_SENTRY_DSN="<YOUR-DSN>"
Note: Full documentation on error handling can be found here.