The project is in a healthy, maintained state
Next.js integration for Capistrano with systemd support, enabling automated deployment and service management for Next.js applications using pnpm
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 3.9, >= 3.9.0
~> 2.7
 Project Readme

Capistrano::Nextjs

Next.js integration for Capistrano with systemd support.

Installation

Add this line to your application's Gemfile:

gem 'capistrano-nextjs'

And then execute:

bundle install

Usage

Add the following to your Capfile:

require 'capistrano/pnpm'
require 'capistrano/nextjs'
install_plugin Capistrano::NextjsPlugin
install_plugin Capistrano::NextjsSystemd

Add the following to your config/deploy.rb:

# Next.js configuration
set :nextjs_roles, :app
set :nextjs_env, fetch(:stage)

Available Tasks

Deployment

  • cap nextjs:start - Start Next.js application
  • cap nextjs:stop - Stop Next.js application
  • cap nextjs:restart - Restart Next.js application
  • cap nextjs:status - Check Next.js application status
  • cap nextjs:install - Install systemd service
  • cap nextjs:uninstall - Uninstall systemd service
  • cap nextjs:build - Build Next.js application
  • cap nextjs:check - Check Next.js application (lint)

Logs

  • cap logs:info - Stream the Next.js application log (green output)
  • cap logs:error - Stream the Next.js error log (red output)
  • cap logs:all - Stream both logs simultaneously, color-coded by source

Press Ctrl+C to stop streaming.

The log tasks use a custom SSHKit formatter to colorize output directly in your terminal:

Task File Color
logs:info shared/log/nextjs.log Green
logs:error shared/log/nextjs-error.log Red
logs:all both Green / Red

Configuration

set :logs_tail_lines, 100  # number of lines to show on connect (default: 100)
set :rake_roles, :app      # roles to stream logs from

Configuration

The gem automatically integrates with your deployment process:

  • Stops the service before deployment
  • Starts the service after successful deployment
  • Restarts the service if deployment fails

Requirements

  • Node.js
  • pnpm
  • systemd (for service management)

License

The gem is available as open source under the terms of the MIT License.