How to set up
2024/10/25

How to set up

How to build your directory website with Mkdirs template

Mkdirs requires several environment variables to function properly, and this guide explains how to set them up.

Create a .env file in the root directory of your project, and never commit it to version control.

You can copy the example file as a starting point:

cp env.example .env

Environment Variables

Core Configuration

VariableDescription
NEXT_PUBLIC_APP_URL"http://localhost:3000" or "https://mkdirs.com"

Database & Storage

Learn how to set up a database in the Sanity Setup guide.

VariableDescription
NEXT_PUBLIC_SANITY_PROJECT_IDSanity project ID
NEXT_PUBLIC_SANITY_DATASETSanity dataset name
SANITY_API_TOKENSanity API token

Authentication

Learn how to set up authentication in the Authentication Setup guide.

VariableDescription
AUTH_SECRETSecret for NextAuth authentication
AUTH_GOOGLE_IDGoogle OAuth client ID
AUTH_GOOGLE_SECRETGoogle OAuth client secret
AUTH_GITHUB_IDGitHub OAuth client ID
AUTH_GITHUB_SECRETGitHub OAuth client secret

Email & Newsletter

Learn how to set up email in the Resend Setup guide.

VariableDescription
RESEND_API_KEYAPI key for Resend email service
RESEND_AUDIENCE_IDAudience ID for Resend broadcast service
RESEND_EMAIL_FROMSender email address
RESEND_EMAIL_ADMINAdmin email address

Payment

Learn how to set up payments in the Stripe Setup guide.

VariableDescription
STRIPE_API_KEYStripe API key
STRIPE_WEBHOOK_SECRETStripe webhook signing secret
NEXT_PUBLIC_STRIPE_PRICE_PRO_MONTHLYStripe price ID for your pro monthly subscription
NEXT_PUBLIC_STRIPE_PRICE_PRO_YEARLYStripe price ID for your pro yearly subscription
NEXT_PUBLIC_STRIPE_PRICE_LIFETIMEStripe price ID for your lifetime subscription
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASICStripe price ID for your basic credit package (optional)
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STANDARDStripe price ID for your standard credit package (optional)
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PREMIUMStripe price ID for your premium credit package (optional)
NEXT_PUBLIC_STRIPE_PRICE_CREDITS_ENTERPRISEStripe price ID for your enterprise credit package (optional)

Analytics

Learn how to set up analytics in the Analytics Setup guide.

VariableDescription
NEXT_PUBLIC_GOOGLE_ANALYTICS_IDGoogle Analytics ID
NEXT_PUBLIC_OPENPANEL_CLIENT_IDOpenPanel Analytics client ID
NEXT_PUBLIC_UMAMI_WEBSITE_IDUmami website ID
NEXT_PUBLIC_UMAMI_SCRIPTUmami script URL
NEXT_PUBLIC_PLAUSIBLE_DOMAINPlausible domain
NEXT_PUBLIC_PLAUSIBLE_SCRIPTPlausible script URL

Affiliates

Learn how to set up affiliates in the Affiliates Setup guide.

VariableDescription
NEXT_PUBLIC_AFFILIATE_AFFONSO_IDAffonso affiliate ID
NEXT_PUBLIC_AFFILIATE_PROMOTEKIT_IDPromotekit affiliate ID

AI Features

Learn how to set up AI features in the AI Setup guide.

VariableDescription
DEFAULT_AI_PROVIDERDefault AI provider for AI features: google, deepseek, openai
GOOGLE_GENERATIVE_AI_API_KEYGoogle Generative AI API key for AI features
OPENAI_API_KEYOpenAI API key for AI features
DEEPSEEK_API_KEYDeepSeek API key for AI features

Background Jobs

Learn how to set up background jobs in the Background Jobs Setup guide.

VariableDescription
INNGEST_SIGNING_KEYInngest signing key for scheduled jobs

Analytics

Learn how to set up analytics in the Analytics Setup guide.

VariableDescription
GOOGLE_ANALYTICS_IDGoogle Analytics ID
UMAMI_WEBSITE_IDUmami Analytics website ID
UMAMI_SCRIPTUmami Analytics script URL
OPENPANEL_CLIENT_IDOpenPanel Analytics client ID
PLAUSIBLE_DOMAINPlausible Analytics domain
PLAUSIBLE_SCRIPTPlausible Analytics script URL
Seline_TOKENSeline Analytics token
DATAFAST_ANALYTICS_IDDataFast Analytics ID
DATAFAST_ANALYTICS_DOMAINDataFast Analytics domain

Notification

Learn how to set up notification in the Notification Setup guide.

VariableDescription
DISCORD_WEBHOOK_URLDiscord webhook URL for receiving notifications of successful payments
FEISHU_WEBHOOK_URLFeishu webhook URL for receiving notifications of successful payments

Captcha

Learn how to set up captcha in the Captcha Setup guide.

VariableDescription
NEXT_PUBLIC_TURNSTILE_SITE_KEYTurnstile site key
TURNSTILE_SECRET_KEYTurnstile secret key

Chatbox

Learn how to set up chatbox in the Chatbox Setup guide.

VariableDescription
NEXT_PUBLIC_CRISP_WEBSITE_IDCrisp website ID for chat features

Affiliates

Learn how to set up affiliates in the Affiliates Setup guide.

VariableDescription
NEXT_PUBLIC_AFFILIATE_AFFONSO_IDAffonso affiliate ID
NEXT_PUBLIC_AFFILIATE_PROMOTEKIT_IDPromotekit affiliate ID

Other Configurations

Some other configurations are also available in the .env file, you may need to set them up depending on your needs.

VariableDescription
DISABLE_IMAGE_OPTIMIZATIONDisable image optimization, if you deploy your website to Vercel, image optimization is enabled by default, and may cost you more money
NEXT_PUBLIC_DEMO_WEBSITERun this website as demo website, I use this for MkSaaS demo website. In most cases, you should not set this or leave it to false

Verifying Environment Variables

To verify that your environment variables are correctly set up, run:

pnpm run dev
npm run dev
yarn dev
bun run dev

If everything is configured correctly, your application should start and run normally without any environment-related errors.

Next Steps

Now that your environment is set up, explore these related topics:

Newsletter

Join the community

Subscribe to our newsletter for the latest news and updates