Qickstart
Get started in about 30 minutes by following these steps.
Preparation
-
Unpack the Archive
-
Switch to the project's root directory
cd basic-next-prisma-authjs- Install the node dependencies
npm install- Copy the sample configuration
cp .env.example .envServices
Database
- Install PostgreSQL via Homebrew, Chocolatey or download it from the website.
brew install postgresql- Add an initial user.
sudo -u postgres psql
CREATE USER postgres WITH PASSWORD 'password';
ALTER USER postgres WITH SUPERUSER;
\q- Update
.envwith your database credentials.
DATABASE_URL=postgresql://postgres:password@localhost:5432/database?schema=public- Apply the database migrations.
npx prisma migrate devGoogle Login (Optional)
- Visit the Google Cloud Console.
- Create an account if you don't have one already.
- Navigate to APIs or click here
- Configure the
OAuth consent screenand add yourself as test user. - Click on
Credentials, create new OAuth credentials and save those credentials. - Add the Authorized JavaScript origin to the credential settings.
http://localhost:3000- Add the Authorized redirect URI to the credential settings.
http://localhost:3000/api/auth/callback/google- Update
.envwith the created credentials.
AUTH_GOOGLE_CLIENT_ID=
AUTH_GOOGLE_CLIENT_SECRET=Microsoft Login (Optional)
- Visit the Azure Portal.
- Create an account if you don't have one already.
- Navigate to your Entra ID (Active Directory).
- Register a new application with platform web.
- Click on
Authenticationin the menu and add the redirect URIs
http://localhost:3000
http://localhost:3000/api/auth/callback/microsoft-entra-id- Under
Certificates & Secrets, create a new client secret. - Update
.envwith the created secret.
AUTH_MICROSOFT_ENTRA_ID_CLIENT_ID=
AUTH_MICROSOFT_ENTRA_ID_CLIENT_SECRET=Billing
Stripe
- Visit the Stripe Dashboard.
- Create an account if you don't have one already.
- Activate test mode.
- Activate the customer billing portal.
- Create a product.
- Create a price for the product.
- Navigate to developer section and copy the API credentials.
- Update
.envwith the IDs and credentials:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
PRO_PRODUCT_ID=
PRO_PRODUCT_PRICE_ID=Billing unit
You can specify the billing unit as per_seat or per_organization. The difference is that per seat you bill for every user in the organization and per_organization you bill for the whole organization regardless of user seats.
BILLING_UNIT=per_seat # per_seat | per_organizationWe recommend to leave it at per_seat if you are not sure.
Webhook
To receive webhooks you can either use the Stripe CLI or ngrok. Let's say you use ngrok. Start ngrok, then go to Developers -> Webhooks and create a new webhook. Enter your ngrok URL + /api/stripe/webhook:
https://randomsubdomain.ngrok-free.app/api/stripe/webhookOpen your newly created webhook and on the right side is a Signing secret. Press reveal and copy the secret, then update .env with the secret:
STRIPE_WEBHOOK_SECRET=SMTP Provider
Achromatic supports both Nodemailer (SMTP) and Resend.
- Choose an email provider (Gmail for testing is fine).
- Update
.envwith your settings/credentials.
EMAIL_SENDER=noreply@mailer.mydomain.com # recommend to use subdomain for transactional/marketing emails
EMAIL_MAILER=Nodemailer # Nodemailer (default) | Resend
# Nodemailer
EMAIL_SERVER_HOST=
EMAIL_SERVER_PORT=
EMAIL_SERVER_USER=
EMAIL_SERVER_PASS=
# Resend
EMAIL_RESEND_API_KEY=Note: For Gmail, you'll need to use an app-specific password. Follow Google's instructions to generate one. Here is an example:
EMAIL_SERVER_HOST=smtp.gmail.com
EMAIL_SERVER_PORT=465
EMAIL_SERVER_PASS=suyz yeba qtgv xrnpGood to know: Sending emails is mandatory for the credentials login.
Application
- Start the Application
npm run dev- Navigate to http://localhost:3000
You’re all set to start!