DEV Community

Cover image for Easily self-host Next.js
Alohe
Alohe

Posted on

Easily self-host Next.js

Introducing quicky

A CLI tool that streamlines the deployment and management of self-hosted Next.js projects, enabling initialization, deployment from GitHub, updating, deleting, and managing applications, along with effortless setup of domains and SSL certificates, simplifying the entire lifecycle of Next.js apps on remote servers.

Features

  • 🐙 GitHub Integration: Initialize, deploy, and manage Next.js projects from private and public GitHub repositories.

  • ⚙️ Process Management: Leverage PM2 for application lifecycle and monitoring.

  • 🔄 Project Maintenance: Easily update or remove deployed projects.

  • 🌐 Domain & SSL Automation: Automatically configure Nginx for custom domains and SSL certificates, allowing you to add/remove domains from your projects.

  • 📝 Configuration Overview: List and inspect details of all deployed projects and their domains.

Prerequisites

To install Quicky, first acquire a Linux Ubuntu server from a provider such as DigitalOcean or Hetzner.

After setting up your server, connect to it (e.g., via SSH) and install Node.js and npm by executing the following commands:

sudo apt update
sudo apt install -y nodejs npm
Enter fullscreen mode Exit fullscreen mode

Installation

Install Quicky globally using either npx or npm:

npx quicky@latest install
Enter fullscreen mode Exit fullscreen mode

or

sudo npm install -g quicky
Enter fullscreen mode Exit fullscreen mode

Note: The sudo command is necessary for global installation and to prevent permission issues when configuring domains.

Usage

1. Initialize Quicky

quicky init
Enter fullscreen mode Exit fullscreen mode

This command will prompt you to enter your GitHub credentials and basic configurations for setting up your projects.

Quicky requires your GitHub access token and username to interact with your repositories. To create a new token, follow these steps:

  1. Visit your GitHub Personal Access Tokens page and make sure to use Tokens (classic).
  2. Click Generate new token.
  3. Select the required scopes for repository access.
  4. Click Generate token.
  5. Copy the token and provide it to Quicky as your GitHub access token which will be stored locally for future use.

2. Deploy a Project

quicky deploy
Enter fullscreen mode Exit fullscreen mode

This command will prompt you to provide:

  • Your GitHub username or any organization name
  • The repository name
  • The port number on which the project should run (e.g., 3000)

Environment Variables - During deployment, you'll be asked whether you'd like to add environment variables to your project.

3. Manage Projects

quicky manage
Enter fullscreen mode Exit fullscreen mode

Lists all deployed projects and allows you to start, stop, restart, update, or delete a specific project.

4. Configuration Overview

quicky list
Enter fullscreen mode Exit fullscreen mode

Displays an overview of all deployed projects, including the following details:

  • PID: Project ID.
  • Owner: GitHub username or organization name.
  • Repository: Name of the GitHub repository.
  • Port: Port number on which the project is running.
  • PM2 Status: Current status of the PM2 process.
  • Last updated: Date and time of the last deployment/update.

5. Domains

Before adding a domain to your project, you need to:

  1. 🛒 Purchase a domain name from a registrar like Namecheap or GoDaddy.
  2. 🌐 Create an A DNS record pointing to your server's IPv4 address.

Once you have your domain, you can easily manage it with the following command:

quicky domains
Enter fullscreen mode Exit fullscreen mode

This command allows you to effortlessly add and remove domains and subdomains for your projects.

6. Upgrade Quicky

quicky upgrade
Enter fullscreen mode Exit fullscreen mode

Upgrades Quicky to the latest version.

8. Uninstall Quicky

quicky uninstall
Enter fullscreen mode Exit fullscreen mode

Removes Quicky from your system.

Feel free to reach out to me on 𝕏 @alemalohe if you have any questions or feedback!

Top comments (0)