A blazingly fast, intelligent CLI tool for scaffolding Next.js projects with automatic GitHub repo creation and optional Vercel deployment. Written in Rust ๐ฆ
- Smart detection - Automatically detects existing components (Next.js, Git, GitHub, Vercel)
- Git-GitHub validation - Verifies local Git is connected to GitHub before deployment
- Push verification - Checks for unpushed commits and offers to push automatically
- Interactive mode - Choose specific operations when no project name is provided
- Zero-config setup - Create a Next.js project with one command
- Automatic GitHub integration - Creates and pushes to a new GitHub repository
- Public/Private repo selection - Choose repository visibility interactively
- Optional Vercel deployment - Deploy to production with URL extraction
- Organized workspace - All projects stored in
~/dev/nextjs/ - Idempotent operations - Safely skip already-completed steps
- Input validation - Validates all user responses before proceeding
- Robust Next.js detection - Supports
.js,.mjs, and.tsconfig files - Zero runtime dependencies - Single compiled binary, no interpreter needed
Before using nextjsinit, ensure you have the following installed:
- Node.js & npm - Required for Next.js
- Git - Version control
- GitHub CLI (
gh) - For automatic repo creation# Install GitHub CLI brew install gh # macOS # or sudo apt install gh # Ubuntu/Debian # Authenticate gh auth login
- Vercel CLI (optional) - For deployment
npm install -g vercel vercel login
Note: The nextjsinit binary itself has no runtime dependencies once compiled!
- Rust & Cargo - Install from rustup.rs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone the repository
git clone https://github.com/vehutech/nextjsinit.git
cd nextjsinit
# Build and install (automatically installs to ~/.cargo/bin)
cargo install --path .
# Make sure ~/.cargo/bin is in your PATH
# Add to ~/.zshrc or ~/.bashrc:
# export PATH="$HOME/.cargo/bin:$PATH"# Clone the repository
git clone https://github.com/vehutech/nextjsinit.git
cd nextjsinit
# Build release binary
cargo build --release
# Copy to system path
sudo cp target/release/nextjsinit /usr/local/bin/
# Verify installation
which nextjsinit# Download from GitHub releases
curl -L https://github.com/vehutech/nextjsinit/releases/latest/download/nextjsinit-macos -o nextjsinit
chmod +x nextjsinit
sudo mv nextjsinit /usr/local/bin/If you have the Lua version of newnextjs or nextjsinit installed:
# Remove old version
sudo rm /usr/local/bin/newnextjs
sudo rm /usr/local/bin/nextjsinit # if Lua version exists
# Install new Rust version as shown abovenextjsinit <project-name>nextjsinitWhen run without arguments, nextjsinit enters interactive mode:
If you're in a Next.js project directory:
๐ Detected current project: my-app
๐ฏ Interactive Mode
๐ Current location: /Users/you/dev/nextjs/my-app
๐ Current Status:
Next.js Project: โ
Git Initialized: โ
GitHub Repo: โ
Git โ GitHub Connected: โ
All Changes Pushed: โ ๏ธ
Vercel Deployed: โ
What would you like to do?
1. Full setup (Next.js + Git + GitHub + Vercel)
2. Next.js project bootstrapping only
3. Git initialization only
4. GitHub repository creation only
5. Vercel deployment only
6. Exit
Enter your choice (1-6):
If you're not in a project directory:
๐ค No project name provided and not in a Next.js project directory.
Enter project name: my-new-app
nextjsinit my-awesome-appOutput:
๐ Initializing project: my-awesome-app
๐ Location: /Users/you/dev/nextjs/my-awesome-app
๐ Creating project directory...
๐ Creating Next.js project: my-awesome-app
[Next.js setup output...]
โ
Next.js project created successfully!
๐ฆ Initializing Git repository...
โ
Git initialized successfully!
๐ Creating GitHub repository...
Should the GitHub repository be public? (y/n): y
โ
GitHub repository created and pushed successfully!
Would you like to deploy this project to Vercel now? (y/n): y
๐ Deploying to Vercel...
โ
Successfully deployed to Vercel!
๐ URL: https://my-awesome-app-xyz123.vercel.app
โ
Project 'my-awesome-app' setup complete!
cd ~/dev/nextjs/existing-project
nextjsinit
# Choose option 4: GitHub repository creation onlycd ~/dev/nextjs/my-project
nextjsinit
# Choose option 5: Vercel deployment onlySmart validation:
โ Git is not initialized. Please initialize Git first (option 3).
# After fixing Git:
โ GitHub repository doesn't exist. Please create it first (option 4).
# After fixing GitHub:
โ Local Git is not connected to GitHub.
Run: git remote add origin https://github.com/YOUR_USERNAME/my-project.git
# After connecting:
โ ๏ธ Warning: You have unpushed changes.
Push changes to GitHub before deploying? (y/n): y
๐ค Pushing changes to GitHub...
โ
Changes pushed successfully!
๐ Deploying to Vercel...
โ
Successfully deployed to Vercel!
๐ URL: https://my-project-xyz123.vercel.app
nextjsinit existing-projectOutput:
๐ Project directory already exists.
โ ๏ธ Next.js project already exists, skipping creation.
โ ๏ธ Git already initialized, skipping.
โ ๏ธ GitHub repository already exists, skipping creation.
Would you like to deploy this project to Vercel now? (y/n): n
๐ Skipping Vercel deployment.
โ
Project 'existing-project' setup complete!
nextjsinit automatically detects:
- Existing project directories
- Next.js project configuration (
.js,.mjs,.tsvariants) - Git initialization status
- GitHub repository existence
- Git remote connection to GitHub
- Unpushed commits
- Vercel deployment status
Before Vercel deployment, nextjsinit verifies:
- โ Vercel CLI is installed
- โ Git is initialized
- โ GitHub repository exists
- โ Local Git is connected to the correct GitHub repo
- โ All changes are pushed (or offers to push automatically)
This prevents deployment failures and ensures code consistency.
All user inputs are validated:
- Yes/no prompts only accept
y/Y/n/N - Menu choices must be valid numbers
- Invalid inputs trigger helpful error messages
Running nextjsinit multiple times safely skips completed steps:
- Won't recreate existing directories
- Won't reinitialize Git if already done
- Won't create duplicate GitHub repositories
- Warns before redeploying to Vercel
When run without arguments, nextjsinit:
- Detects if you're in a project directory
- Shows current project status with connection details
- Offers relevant operations based on current state
Edit line 4 in the script:
local baseDir = os.getenv("HOME") .. "/dev/nextjs"
-- Change to your preferred location:
local baseDir = os.getenv("HOME") .. "/projects"Modify the createNextJsProject function (around line 95):
local cmd = string.format("cd \"%s\" && npx create-next-app@latest ./ --typescript --tailwind --app", projectPath)After running nextjsinit my-app:
~/dev/nextjs/
โโโ my-app/
โโโ .git/
โโโ .gitignore
โโโ next.config.js
โโโ package.json
โโโ README.md
โโโ app/
โโโ public/
โโโ node_modules/
Ensure the script is in your $PATH:
echo $PATH
# Move script to a directory in PATH
sudo mv nextjsinit /usr/local/bin/
chmod +x /usr/local/bin/nextjsinitInstall GitHub CLI:
brew install gh # macOS
sudo apt install gh # Ubuntu/Debian
gh auth loginnpm install -g vercel
vercel loginchmod +x /usr/local/bin/nextjsinitgh auth status
gh auth login --webMake sure you're entering exactly y or n (lowercase or uppercase) for yes/no prompts, and valid numbers for menu choices.
Check the pre-deployment validation:
# Verify Git is connected to GitHub
git remote -v
# Should show:
# origin https://github.com/username/project.git (fetch)
# origin https://github.com/username/project.git (push)
# Check for unpushed commits
git status
# Push if needed
git push origin main# Add GitHub remote manually
git remote add origin https://github.com/YOUR_USERNAME/PROJECT_NAME.git
# Verify
git remote -v
# Push
git push -u origin main| Option | Description | When to Use |
|---|---|---|
| 1. Full setup | Creates Next.js + Git + GitHub + Vercel | Starting a brand new project |
| 2. Next.js only | Bootstraps Next.js project | You want to handle Git/GitHub manually |
| 3. Git only | Initializes Git repository | Adding version control to existing project |
| 4. GitHub only | Creates and pushes to GitHub | Publishing existing local project |
| 5. Vercel only | Deploys to Vercel | Deploying already-configured project |
| 6. Exit | Quits the program | Changed your mind |
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m "Add amazing feature" - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
MIT License - see LICENSE file for details
- Next.js - The React framework
- Vercel - Deployment platform
- GitHub CLI - GitHub automation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Smart component detection
- Interactive mode
- Public/private repo selection
- Input validation
- Vercel URL extraction
- Git-GitHub connection validation
- Unpushed commits detection
- Automatic push before deployment
- Robust Next.js config detection (.js/.mjs/.ts)
- Template support (blog, e-commerce, dashboard)
- Command-line flags (
--skip-github,--skip-vercel, etc.) - Integration with other platforms (Netlify, Railway)
- Configuration file support (
.nextjsinitrc) - Database initialization (Prisma, Supabase)
- Automated testing setup
- CI/CD pipeline templates
- Pre-commit hooks configuration
- Environment variable management