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 installCreate 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
Connectbutton to view your connection string. - Update the connection string in your
.envfile.
POSTGRES_URL="<your-connection-string>?workaround=supabase-pooler.vercel"Note: Notice how the connection string has a
?workaround=supabase-pooler.vercelat 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_URLenv will be set in your project. - Update the connection string in your
.envfile.
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:migrateNote: 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 devOpen your browser and navigate to http://localhost:3000.
openssl rand -base64 32Update 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_KEYin your.envfile.
RESEND_API_KEY="YOUR-API-KEY"- Update the
AUTH_EMAIL_FROMin your.envfile.
AUTH_EMAIL_FROM="Acme <signin@example.com>"- 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_IDandAUTH_GOOGLE_SECRETin your.envfile.
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 your-email@example.comNote: This will grant the user the admin role in the database based on your local
POSTGRES_URLenv 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_KEYandSTRIPE_SECRET_KEYin your.envfile.
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 devNote: Make sure you don't have the coming soon page enabled locally in your
.envfile.
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_SECRETin your.envfile.
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:studioNote: 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
Audiencesand create a new audience. - Copy the audience id and update the
RESEND_NEWSLETTER_AUDIENCE_IDin your.envfile.
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_HOSTin your.envfile.
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_ORGin your.envfile.
SENTRY_ORG="<YOUR-ORGANIZATION-SLUG>"- Create a new project and note the
Project Name. - Update the
SENTRY_PROJECTin your.envfile.
SENTRY_PROJECT="<YOUR-PROJECT-NAME>"- Create a new auth token. Click
Settings->Auth Tokens->Create Auth Token. - Update the
SENTRY_AUTH_TOKENin your.envfile.
SENTRY_AUTH_TOKEN="<YOUR-AUTH-TOKEN>"- Create a new client key. Click
Settings->Client Keyscopy the DSN orGenerate New Key. - Update the
NEXT_PUBLIC_SENTRY_DSNin your.envfile.
NEXT_PUBLIC_SENTRY_DSN="<YOUR-DSN>"Note: Full documentation on error handling can be found here.