Skip to content

Getting Started

Prerequisites

  • Node.js 22 or higher
  • npm 9 or higher (or pnpm/yarn)
bash
node -v
npm -v

Installation

Global Install

bash
npm install -g tsnap

Or Use npx

No installation needed:

bash
npx tsnap --version

TIP

Use npx tsnap instead of tsnap in all commands if you prefer not to install globally.

Quick Start

Create a Project

bash
tsnap init my-project

You'll be prompted with interactive questions:

✔ Use ESLint? (Y/n)
✔ Use Prettier?  (Y/n)
✔ Run npm install now? (Y/n)
ℹ️ Creating project at /path/to/my-project
✅️ Project created
✨ Project initialization is completed

Then navigate to your project:

bash
cd my-project

TIP

You can choose which tools to include during initialization, or add them later with tsnap add.

Project Structure

After initialization:

my-project/
├── src/
│   └── index.ts
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md

Adding Tools Later

Add development tools anytime after initialization:

bash
# Add ESLint
tsnap add eslint

# Add Prettier
tsnap add prettier

# Add Vite (with interactive template selection)
tsnap add vite

When adding Vite, you'll choose a template:

? Select a Vite template:
❯ Vanilla (TypeScript)
  React (TypeScript)

WARNING

tsnap won't overwrite existing files without confirmation.

Available Tools

ToolDescriptionCommand
ESLintTypeScript lintertsnap add eslint
PrettierCode formattertsnap add prettier
ViteBuild tool & dev servertsnap add vite

Example Workflows

Minimal Setup (No Tools)

bash
# With global install
tsnap init my-project
# Answer "No" to all prompts
cd my-project
npm install

Full Setup (All Tools)

bash
# With global install
tsnap init my-project
# Answer "Yes" to ESLint and Prettier
cd my-project
tsnap add vite
npm run dev

Using npx

bash
# No installation needed
npx tsnap init my-project
cd my-project
npx tsnap add vite
npm install
npm run dev

Common Commands

bash
tsnap --version        # Check version
tsnap --help           # View help
tsnap init <name>      # Create project (interactive)
tsnap add <tool>       # Add tool

Next Steps

  • Configure tsconfig.json for your needs
  • Explore tool-specific documentation
  • Start building your TypeScript application