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:
-
Go to https://clerk.com and create an account.
-
Create a new application.
-
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
Dashboard → Your App → API Keys
📽️ Video Guide:
Create Webhooks
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:
- 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
- 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
- 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.
- 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
- 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:
-
Go to https://neon.tech and sign up.
-
Create a new project.
-
Select “Next.js” or “Other” as your stack.
-
After creation, go to Project → Connection Details.
-
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
📺 5. YouTube API Key
NexTube supports importing YouTube videos using the YouTube Data API (for importing videos)
🧭 How to get your YouTube API key:
-
Go to Google Cloud Console .
-
Create a new project (or select an existing one).
-
Navigate to APIs & Services → Library.
-
Search for YouTube Data API v3 and click Enable.
-
Go to APIs & Services → Credentials.
-
Click “Create Credentials” → API key.
-
Copy the generated key.
YOUTUBE_API_KEY=your_api_key_here
📽️ Video Guide:
✅ 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