NextJS

The configuration for NodeJS is located at the .env file. You can find more information at src/env.server.ts, which is the .env validator.

Installing NodeJS

Make sure you have NodeJS installed on your machine. The recommended version is 18.

Is recommended that you use a Node Version Manager tool for you to be able to switch version if you need it in the future.

MacOS/Linux: https://github.com/nvm-sh/nvm

Windows: https://github.com/coreybutler/nvm-windows

Installing the Database

Please make sure you have PostgreSQL installed and running on your machine.

Also, make sure you have access to that database using a database GUI tool.

Configuring .env variables

The .env file is located at .env and it stores the environment variables.

Database

If you are using the default PostgreSQL database on your localhost, you can leave the configuration as it is.

DATABASE_URL="postgresql://appuser@localhost:5432/scaffoldhub-localhost-app?schema=public"
DATABASE_MIGRATION_URL="postgresql://postgres@localhost:5432/scaffoldhub-localhost-app?schema=public"
DATABASE_NAME="postgres"
DATABASE_APP_PASSWORD="appuser"
DATABASE_APP_USER="appuser"
DATABASE_SCHEMA="public"

Note the DATABASE_URL uses the appuser and the DATABASE_MIGRATION_URL uses postgres. This is proposital. In order to make use of Row Level Security (RLS), the user the app uses must NOT have superuser privileges. In other hand, the user that runs the migration must.

Backend and Frontend URLs

You can leave this configuration as it is. The backend URL is only required in case you want do have different servers to handle frontend and backend, but usually it's not the case.

NEXT_PUBLIC_BACKEND_URL=""
FRONTEND_URL="http://localhost:3000"

Tenant Mode

The tenant mode can be "multi" or "single". It depends if you want your application to have multiple tenants/workspaces/organizations or just one.

NEXT_PUBLIC_TENANT_MODE="multi"

Authorization

The token secret is used to sign JWT tokens. Please replace the JWT secret to some random and long UUID chain. For example: a40a8850-24b2-4023-85ce-1765d10c849b-758df0c2-b112-4851-960d-1b7163d3ccd6

The JWT expiration invalidates the tokens after a certain period that can be configured on the AUTH_JWT_EXPIRES_IN variable.

Google, Facebook, and Github secrets are used for oAuth authentication. They are optional.

The Bypass Email Verification flag is used to skip email verification for new users.

AUTH_TOKEN_SECRET="complex_password_at_least_32_characters_long"
AUTH_TOKEN_EXPIRES_IN="7 days"

NEXT_PUBLIC_AUTH_GOOGLE_ID=""
AUTH_GOOGLE_SECRET=""
NEXT_PUBLIC_AUTH_FACEBOOK_ID=""
AUTH_FACEBOOK_SECRET=""
NEXT_PUBLIC_AUTH_GITHUB_ID=""
AUTH_GITHUB_SECRET=""

AUTH_BYPASS_EMAIL_VERIFICATION="false"

Recaptcha

The app optionally uses Recaptcha to prevent abuse on the authorization process. If you want to enable it, replace with your Recaptcha credentials.

NEXT_PUBLIC_RECAPTCHA_SITE_KEY=""
RECAPTCHA_SECRET_KEY=""

Subscription and Payments

If you're using subscriptions and payments, you need to setup the Stripe variables. Go to Setup > Payments with Stripe for full details.

NEXT_PUBLIC_SUBSCRIPTION_MODE="membership"
STRIPE_SECRET_KEY=""
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=""
NEXT_PUBLIC_SUBSCRIPTION_PRICES_BASIC=""
NEXT_PUBLIC_SUBSCRIPTION_PRICES_ENTERPRISE=""
STRIPE_WEBHOOK_SECRET=""

Storage

For storage configuration, go to Setup > File Storage.

FILE_STORAGE_PROVIDER="local"
FILE_STORAGE_BUCKET=""
FILE_STORAGE_LOCAL_FOLDER=""
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
GOOGLE_CLOUD_PLATFORM_CREDENTIALS=""

Email

To send emails you must configure the SMTP settings.

EMAIL_FROM="felipe@scaffoldhub.io"
EMAIL_SMTP_HOST=""
EMAIL_SMTP_PORT=""
EMAIL_SMTP_USER=""
EMAIL_SMTP_PASSWORD=""

Installing the Dependencies

Go to the root of your project and run:

npm install

You can ignore installation warnings.

Setting up the Database

Go to the root of your project and run:

npm run setup

This will create the database you set on the .env file with the application schema.

Running the app

Go to the root of your project and run:

npm run dev

Last updated