Skip to Content
NexTube 3.0 is released 🎉
InstallationBefore starting installation

Before starting installation

Environment Variables Configuration

Before you can run NexTube, you need to properly configure your .env file. This section provides a complete guide to generating and adding all necessary credentials, including Clerk, Neon.tech (PostgreSQL database), and YouTube API.


🔑 Required .env

Here’s the list of environment variables you must fill in:

# Domain name NEXT_PUBLIC_APP_URL= # Clerk authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= CLERK_SECRET_KEY= CLERK_WEBHOOK_SIGNING_SECRET= NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/ NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/ # Database (PostgreSQL) or (NeonDB database) DATABASE_URL= # License key LICENSE_KEY= # YouTube Data API key YOUTUBE_API_KEY=

🌐 1. Set Your Domain Name

NEXT_PUBLIC_APP_URL=https://yourdomain.com

If you’re testing locally, use:

NEXT_PUBLIC_APP_URL=http://localhost:3000

🔐 2. Clerk Auth Setup

Clerk is used for user authentication and account management.

🧭 Step-by-step guide:

  1. Go to https://clerk.com and create an account.

  2. Create a new application.

  3. Under your app dashboard, navigate to API Keys and copy the following:

✅ Required Clerk values:

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_publishable_key CLERK_SECRET_KEY=your_secret_key
Note

Dashboard → Your App → API Keys

📽️ Video Guide:

Create Webhooks

Note

Dashboard → Configure → Webhooks

📽️ Video Guide:

Clerk Webhook .env

CLERK_WEBHOOK_SIGNING_SECRET=whsec_.....

Endpoint URL:

https://yourdomain.com/api/users/webhook

🗄️ 3. Neon.tech PostgreSQL Database or PostgreSQL Database Setup on VPS

You can choose between two options for setting up your PostgreSQL database:

Neon.tech PostgreSQL Database: Use a fully-managed, serverless PostgreSQL database provided by Neon.tech.

PostgreSQL Database Setup on VPS: Set up and manage your own PostgreSQL database on a Virtual Private Server (VPS).

🗄️ 3.1 PostgreSQL Database Setup on VPS

🧭 How to Set Up PostgreSQL on Your VPS:

  1. Install PostgreSQL:

Start by installing PostgreSQL on your server. On Ubuntu, you can do this with the following commands:

sudo apt update sudo apt install postgresql postgresql-contrib
  1. Start PostgreSQL Service:

After installation, start the PostgreSQL service:

sudo service postgresql start

To check if PostgreSQL is running, use the command:

sudo service postgresql status
  1. Create a PostgreSQL Database:

Log into PostgreSQL as the default postgres user:

sudo -u postgres psql

Then, create a new database and user for your application:

CREATE DATABASE nexTubeDB; CREATE USER nexTubeUser WITH PASSWORD 'your_password'; ALTER ROLE nexTubeUser SET client_encoding TO 'utf8'; ALTER ROLE nexTubeUser SET default_transaction_isolation TO 'read committed'; ALTER ROLE nexTubeUser SET timezone TO 'UTC'; GRANT ALL PRIVILEGES ON DATABASE nexTubeDB TO nexTubeUser;

Replace nexTubeDB with the name of your database and nexTubeUser with the username you wish to use.

  1. Configure PostgreSQL to Allow Remote Connections (Optional):

If your server needs to be accessed remotely, open the PostgreSQL configuration file:

4.1 Check PostgreSQL Version:

To check the installed version of PostgreSQL, run the following command:

psql --version

This will display the PostgreSQL version, for example:

psql (PostgreSQL) 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)

Make sure to replace 12 with your actual version number when referring to configuration files later.

For PostgreSQL version 12, the configuration file is located at /etc/postgresql/12/main/pg_hba.conf. If you are using a different version of PostgreSQL, replace 12 with the version number you are using. For example, for PostgreSQL 13, the path will be /etc/postgresql/13/main/pg_hba.conf.

sudo nano /etc/postgresql/12/main/pg_hba.conf

Add the following line to allow connections from a specific IP address (replace your_ip_address with the actual IP):

host all all your_ip_address/32 md5

Then, restart PostgreSQL to apply the changes:

sudo service postgresql restart
  1. Find Your Connection String:

The connection string for your PostgreSQL database will look something like this:

DATABASE_URL=postgresql://nexTubeUser:your_password@your_vps_ip/nexTubeDB?sslmode=require
  • nexTubeUser: The username you created.
  • your_password: The password you set for the user.
  • your_vps_ip: The IP address of your VPS.
  • nexTubeDB: The name of your database.

Update .env File:

After setting up the PostgreSQL database, add the connection string to your .env file:

DATABASE_URL=postgresql://nexTubeUser:your_password@your_vps_ip/nexTubeDB?sslmode=require

Ensure that the sslmode=require is included to enforce secure connections.


🗄️ 3.2 Neon.tech PostgreSQL Database

Neon is a fully-managed Postgres database with a free tier.

🧭 How to create your Neon DB:

  1. Go to https://neon.tech and sign up.

  2. Create a new project.

  3. Select “Next.js” or “Other” as your stack.

  4. After creation, go to Project → Connection Details.

  5. Copy the connection string.

It should look like:

DATABASE_URL=postgresql://USER:PASSWORD@HOST/DB_NAME?sslmode=require
💡

Make sure you select Connection string (password) and include sslmode=require.

📽️ Video Guide:

🧾 4. License Key

You’ll need a valid license key to activate NexTube.

LICENSE_KEY=YOUR_LICENSE_KEY
You should have received this key via email or through the purchase portal https://pay.jooj.us

📺 5. YouTube API Key

NexTube supports importing YouTube videos using the YouTube Data API (for importing videos)

🧭 How to get your YouTube API key:

  1. Go to Google Cloud Console.

  2. Create a new project (or select an existing one).

  3. Navigate to APIs & Services → Library.

  4. Search for YouTube Data API v3 and click Enable.

  5. Go to APIs & Services → Credentials.

  6. Click “Create Credentials” → API key.

  7. Copy the generated key.

YOUTUBE_API_KEY=your_api_key_here

📽️ Video Guide:

💡
✅ Don’t forget to restrict your API key to avoid abuse.

✅ Final Check

After adding all values, your .env file should look like this (with your actual keys filled in):

NEXT_PUBLIC_APP_URL=https://yourdomain.com NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxx CLERK_SECRET_KEY=sk_test_xxxx NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/ NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/ DATABASE_URL=postgresql://user:password@host/dbname?sslmode=require LICENSE_KEY=LIC-XXXX-XXXX YOUTUBE_API_KEY=AIzaSyXXXX