Vix.cpp v2.6.0 is here Read the blog
Skip to content

vix new

vix new creates a new Vix project.

Use it when you want to start an application, backend service, web project, Vue fullstack project, game project, or reusable C++ library.

bash
vix new api
1

Overview

vix new is the project creation command in Vix.

It creates a ready-to-use project with:

  • source files
  • project configuration
  • Vix metadata
  • generated tasks
  • build setup
  • runtime configuration when needed
  • template-specific structure

It is the recommended way to start a Vix project because it creates a structure that works immediately with:

bash
vix build
vix run
vix dev
vix tests
vix check
vix task
1
2
3
4
5
6

Usage

bash
vix new <name|path> [options]
1

Basic examples

bash
# Create a default application
vix new api

# Create a project in the current directory
vix new .

# Create a backend service
vix new api --template backend

# Create a server-rendered web project
vix new blog --template web

# Create a Vue fullstack project
vix new dashboard --template vue

# Create a game project
vix new mario --game

# Create a game project with template syntax
vix new platformer --template game

# Create a header-only library
vix new tree --lib

# Create inside another directory
vix new blog -d ./projects

# Overwrite an existing directory
vix new api --force
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

What vix new can create

TypeCommandUse when
Applicationvix new apiYou want a small runnable C++ app.
Applicationvix new api --appYou want to be explicit about the default app template.
Backendvix new api --template backendYou want a production-oriented API or backend service.
Webvix new blog --template webYou want server-rendered HTML with Vix.
Vuevix new dashboard --template vueYou want a Vue frontend with a Vix C++ backend.
Gamevix new mario --gameYou want a Vix game project.
Gamevix new mario --template gameSame idea using template syntax.
Libraryvix new tree --libYou want a reusable header-only C++ library.

Default behavior

By default, vix new creates an application project.

bash
vix new api
1

This is equivalent to:

bash
vix new api --app
1

Use the default application template when you want:

  • a small executable app
  • a simple HTTP app
  • a local tool
  • a demo
  • a prototype
  • a project that can grow later

Application template

Create an application:

bash
vix new hello
1

or:

bash
vix new hello --app
1

Enter the project:

bash
cd hello
1

Build it:

bash
vix build
1

Run it:

bash
vix run
1

Start development mode:

bash
vix dev
1

The application template is the smallest real Vix project.

It is useful when you want to start clean without a large backend, web, Vue, game, or library structure.

Backend template

Create a backend project:

bash
vix new api --template backend
1

Enter the project:

bash
cd api
1

Create your local environment file:

bash
cp .env.example .env
1

Start development mode:

bash
vix dev
1

Test the health endpoint:

bash
curl http://127.0.0.1:8080/health
1

Use the backend template when you need:

  • API routes
  • production-oriented folders
  • config files
  • health endpoints
  • middleware-ready structure
  • database-ready structure
  • a stronger backend foundation than the default app template

Web template

Create a web project:

bash
vix new blog --template web
1

Enter the project:

bash
cd blog
1

Create your local environment file:

bash
cp .env.example .env
1

Start development mode:

bash
vix dev
1

Open:

txt
http://127.0.0.1:8080
1

Use the web template when you want:

  • server-rendered HTML
  • static assets
  • Vix templates
  • a simple web app structure
  • an app that does not need a separate frontend framework

Vue template

Create a Vue fullstack project:

bash
vix new dashboard --template vue
1

Enter the project:

bash
cd dashboard
1

Install dependencies when needed:

bash
vix install
1

Start development mode:

bash
vix dev
1

Use the Vue template when you want:

  • a Vue frontend
  • a Vix C++ backend
  • one fullstack project
  • frontend and backend development together

In dev mode, Vix can detect the Vue frontend and start the frontend dev server when the project contains the expected frontend structure.

Game template

Create a game project:

bash
vix new mario --game
1

or:

bash
vix new mario --template game
1

Enter the project:

bash
cd mario
1

Build it:

bash
vix build
1

Run it:

bash
vix run
1

Use the game template when you want:

  • a game-oriented project structure
  • a simulation
  • a real-time prototype
  • a custom engine foundation
  • a project based on the Vix game runtime

Library template

Create a header-only library:

bash
vix new tree --lib
1

Enter the project:

bash
cd tree
1

Build the generated project:

bash
vix build --build-target all
1

Enable tests:

bash
vix build --build-target all -- -Dtree_BUILD_TESTS=ON
1

Run tests:

bash
vix tests
1

Use the library template when you want:

  • reusable C++ code
  • a header-only package
  • an include/ directory
  • tests
  • examples
  • a future package for the Vix Registry

Why libraries use --build-target all

vix build builds the main project target by default.

For an application named api, this works because the generated project creates an executable target named:

txt
api
1

For a header-only library named tree, the project usually exposes an interface target and optional tests or examples.

So for generated libraries, use:

bash
vix build --build-target all
1

This asks CMake and Ninja to build all enabled generated targets.

Template selection

You can select a template with a flag:

bash
vix new api --app
vix new tree --lib
vix new mario --game
1
2
3

You can also use --template:

bash
vix new api --template backend
vix new blog --template web
vix new dashboard --template vue
vix new platformer --template game
1
2
3
4

Supported --template values:

txt
backend
web
vue
game
1
2
3
4

Interactive mode

When Vix can interact with the terminal and you do not provide a specific template, it can ask you to choose a template interactively.

This is useful when you run:

bash
vix new myproject
1

and want to choose the project type from a menu.

In scripts or CI, use explicit flags or non-interactive mode.

Non-interactive mode

Use VIX_NONINTERACTIVE=1 to disable prompts:

bash
VIX_NONINTERACTIVE=1 vix new api
1

Create a library without prompts:

bash
VIX_NONINTERACTIVE=1 vix new tree --lib
1

CI also disables prompts:

bash
CI=1 vix new api
1

Use non-interactive mode when running vix new from scripts, CI jobs, or automated setup commands.

Create in the current directory

Use . to initialize the current directory:

bash
vix new .
1

This is useful when you already created the repository manually.

Example:

bash
mkdir api
cd api
git init
vix new .
1
2
3
4

If the current directory is not empty, Vix may ask for confirmation in interactive mode.

In non-interactive mode, use --force if you intentionally want to write template files into the current directory.

bash
vix new . --force
1

Create inside another directory

Use -d or --dir to choose the base directory:

bash
vix new blog -d ./projects
1

This creates:

txt
./projects/blog
1

Equivalent form:

bash
vix new blog --dir ./projects
1

Overwrite an existing directory

By default, Vix avoids overwriting existing project files.

Use --force only when you intentionally want to overwrite an existing directory:

bash
vix new api --force
1

Use this carefully.

If the destination exists and is not empty, files may be replaced.

Conflicting options

Choose only one project type.

Wrong:

bash
vix new api --app --lib
1

Wrong:

bash
vix new api --lib --template backend
1

Wrong:

bash
vix new game --game --template vue
1

Correct:

bash
vix new api --app
1

or:

bash
vix new api --template backend
1

or:

bash
vix new tree --lib
1

or:

bash
vix new mario --game
1

Generated application structure

A generated application has a structure similar to:

txt
api/
├── CMakeLists.txt
├── CMakePresets.json
├── README.md
├── api.vix
├── vix.json
├── .env
├── .env.example
├── src/
│   └── main.cpp
└── tests/
    └── test_basic.cpp
1
2
3
4
5
6
7
8
9
10
11
12

The executable target matches the project name.

For example:

bash
vix new api
cd api
vix build
1
2
3

This builds the api target.

Generated backend structure

A generated backend project has a production-oriented structure.

It can include folders for routes, handlers, middleware, configuration, and application code.

The exact structure can evolve with Vix versions, but the purpose stays the same:

txt
backend template
-> production-oriented C++ API foundation
1
2

Use it when the project is meant to become a real backend service.

Generated web structure

A generated web project is designed for server-rendered web apps.

It can include:

txt
src/
templates/
public/
.env
.env.example
vix.json
1
2
3
4
5
6

Use it when you want Vix to serve HTML, templates, and static files.

Generated Vue structure

A generated Vue project is a fullstack project.

It can include:

txt
backend C++ app
frontend/
frontend/package.json
vix.json
.env
.env.example
1
2
3
4
5
6

Use vix dev to run the development workflow.

Generated game structure

A generated game project is designed for Vix game workflows.

It can include:

txt
src/
assets/
CMakeLists.txt
CMakePresets.json
vix.json
README.md
1
2
3
4
5
6

Use:

bash
vix build
vix run
1
2

to build and start the game.

Generated library structure

A generated header-only library has a structure similar to:

txt
tree/
├── CMakeLists.txt
├── CMakePresets.json
├── README.md
├── tree.vix
├── vix.json
├── include/
│   └── tree/
│       └── tree.hpp
├── examples/
│   ├── CMakeLists.txt
│   └── basic.cpp
└── tests/
    └── test_basic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Build it with:

bash
vix build --build-target all
1

Enable tests with:

bash
vix build --build-target all -- -Dtree_BUILD_TESTS=ON
1

Run tests:

bash
vix tests
1

Generated manifest files

A new project can include:

txt
vix.json
<project>.vix
vix.app
1
2
3

The exact files depend on the template.

vix.json

vix.json stores project metadata, dependencies, variables, and reusable tasks.

It is used by commands such as:

bash
vix task
vix add
vix install
vix check
1
2
3
4

<project>.vix

Some templates generate a .vix manifest file.

It can be used with commands such as:

bash
vix run app.vix
vix dev app.vix
1
2

vix.app

Some templates use the vix.app workflow.

vix.app describes a simple Vix application target.

It can be used by:

bash
vix build
vix run
vix dev
1
2
3

without requiring the user to manually write a CMakeLists.txt for simple apps.

Generated tasks

Generated projects can include reusable tasks in vix.json.

Examples:

bash
vix task dev
vix task test
vix task ci
1
2
3

Tasks make project workflows repeatable.

The exact generated tasks depend on the template.

Feature selection

For some templates, interactive mode can ask which features you want.

Feature selection can apply to application, backend, or Vue projects.

Examples of feature categories can include:

  • database support
  • static runtime options
  • full static options
  • backend-related project features

The exact available features can evolve with Vix versions.

In non-interactive mode, choose the template explicitly and configure features later.

Application workflow

Create:

bash
vix new api
1

Enter:

bash
cd api
1

Build:

bash
vix build
1

Run:

bash
vix run
1

Develop:

bash
vix dev
1

Backend workflow

Create:

bash
vix new api --template backend
1

Enter:

bash
cd api
1

Create local env:

bash
cp .env.example .env
1

Start dev mode:

bash
vix dev
1

Test health:

bash
curl http://127.0.0.1:8080/health
1

Web workflow

Create:

bash
vix new blog --template web
1

Enter:

bash
cd blog
1

Create local env:

bash
cp .env.example .env
1

Start dev mode:

bash
vix dev
1

Open:

txt
http://127.0.0.1:8080
1

Vue workflow

Create:

bash
vix new dashboard --template vue
1

Enter:

bash
cd dashboard
1

Install dependencies when needed:

bash
vix install
1

Start dev mode:

bash
vix dev
1

Game workflow

Create:

bash
vix new mario --game
1

Enter:

bash
cd mario
1

Build:

bash
vix build
1

Run:

bash
vix run
1

Library workflow

Create:

bash
vix new tree --lib
1

Enter:

bash
cd tree
1

Build all generated targets:

bash
vix build --build-target all
1

Enable tests:

bash
vix build --build-target all -- -Dtree_BUILD_TESTS=ON
1

Run tests:

bash
vix tests
1

After project creation

Common next commands:

bash
cd <project>
vix build
vix run
vix dev
1
2
3
4

If the project has dependencies:

bash
vix install
1

If you want validation:

bash
vix check
1

If you want tests:

bash
vix tests
1

If you want to run generated tasks:

bash
vix task <name>
1

Options

OptionDescription
<name|path>Project name or destination path.
--appGenerate an application project. This is the default.
--applicationAlias-style application option.
--type=appGenerate an application project.
--type=applicationGenerate an application project.
--libGenerate a header-only library project.
--libraryAlias-style library option.
--type=libGenerate a library project.
--type=libraryGenerate a library project.
--gameGenerate a game project.
--type=gameGenerate a game project.
--template <name>Generate a template project: backend, web, vue, or game.
--template=<name>Same as --template <name>.
-d, --dir <path>Base directory for project creation.
--dir=<path>Same as --dir <path>.
--forceOverwrite an existing directory or write into a non-empty current directory.
-h, --helpShow command help.

Environment variables

VariableDescription
VIX_NONINTERACTIVE=1Disable interactive prompts.
CI=1Disable interactive prompts in CI environments.

Examples:

bash
VIX_NONINTERACTIVE=1 vix new api
VIX_NONINTERACTIVE=1 vix new tree --lib
CI=1 vix new api --template backend
1
2
3

Common mistakes

Running commands outside the generated project

Wrong:

bash
vix new api
vix dev
1
2

Correct:

bash
vix new api
cd api
vix dev
1
2
3

Creating a library when you need an app

Wrong for a backend service:

bash
vix new api --lib
1

Correct:

bash
vix new api
1

or:

bash
vix new api --template backend
1

Using vix build directly in a header-only library

Wrong:

bash
vix new tree --lib
cd tree
vix build
1
2
3

Correct:

bash
vix new tree --lib
cd tree
vix build --build-target all
1
2
3

Running library tests before enabling them

Wrong:

bash
vix new tree --lib
cd tree
vix tests
1
2
3

Correct:

bash
vix new tree --lib
cd tree
vix build --build-target all -- -Dtree_BUILD_TESTS=ON
vix tests
1
2
3
4

Combining incompatible project types

Wrong:

bash
vix new api --lib --template backend
1

Correct:

bash
vix new api --template backend
1

Using --force too early

Avoid this unless you really want to overwrite files:

bash
vix new api --force
1

Prefer creating a clean folder first.

Troubleshooting

Missing project name

Wrong:

bash
vix new --template backend
1

Correct:

bash
vix new api --template backend
1

Unknown template

Wrong:

bash
vix new app --template desktop
1

Supported templates:

txt
backend
web
vue
game
1
2
3
4

Correct:

bash
vix new app --template backend
1

Directory is not empty

If the target directory exists and is not empty, Vix will avoid overwriting by default.

Use a clean directory or pass:

bash
vix new api --force
1

only when you intentionally want to overwrite.

Base directory is invalid

Wrong:

bash
vix new blog --dir ./missing-folder
1

Create the base directory first:

bash
mkdir -p ./projects
vix new blog --dir ./projects
1
2

Build target not found in a library

You are probably in a generated header-only library.

Use:

bash
vix build --build-target all
1

No tests available in a library

Enable tests first:

bash
vix build --build-target all -- -Dtree_BUILD_TESTS=ON
1

Then run:

bash
vix tests
1

Replace tree with your project name.

When to use each template

Use the application template when you want the smallest runnable app. Use the backend template when you want a production-oriented API or backend service. Use the web template when you want server-rendered HTML. Use the Vue template when you want a frontend and backend in one project. Use the game template when you want a game, simulation, prototype, or custom engine foundation. Use the library template when you want reusable C++ code that can later be packaged and shared.

CommandPurpose
vix buildBuild the generated project.
vix runBuild and run the generated app.
vix devStart development mode with reload.
vix testsRun tests.
vix checkValidate the project.
vix installInstall project dependencies.
vix addAdd dependencies.
vix taskRun generated or custom tasks.

Next step

Build the generated project.

Open the vix build guide

Released under the MIT License.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.