Blog

What's the Vaadin CLI?

By  
Mikael Sukoinen
Mikael Sukoinen
·
On May 20, 2021 1:00:46 PM
·
In Product

vaadin-cli-featured-image

The Vaadin command line interface (CLI) is a fast way to create a new Vaadin Flow or Fusion project directly from your local terminal. Vaadin CLI is experimental and free to use.

Prerequisites: you need to have Node.js installed. Go to the Node.js download page to install it on your development machine (macOS, Windows or Linux-compatible). You can run the following command to verify if Node is already installed: node -v

The Vaadin CLI can only be used to create new projects at the moment, but we are planning to develop it further. What new features would you like to see?

You can also go to start.vaadin.com to configure and download a Vaadin project without using the Vaadin CLI.

Install the Vaadin CLI

After verifying that you have Node.js installed, open a terminal window and enter and execute the following command:

npm i -g @vaadin/cli

Use the Vaadin CLI

Open a new terminal window in the folder where you wish to create a new project, and run the command below. Replace my-project with the application name.

vaadin init my-project

You can see the project being built in your terminal:

mikael@MacBook-Pro Example app folder % vaadin init my-project
Creating application 'my-project'
Project 'my-project' created

 

You can also create a Vaadin Fusion project by adding the --fusion tag.

vaadin init --fusion my-project

The command creates a new subdirectory to the folder, containing the newly created Flow app. Start the project by running the following commands in the terminal window:

cd my-project

mvn

The app should automatically open in a new tab/window in your default browser. If not, watch the app being built and manually navigate to http://localhost:8080/ to view it.

Example app view

Figure 1. View of the created example app.

Other commands

You can use the CLI to test the latest Vaadin pre-release version by adding the --pre annotation to the command. And, as previously mentioned, replace my-project with the desired name of your app

vaadin init --pre my-project

You can also build applications with different presets. Replace <preset> with the desired preset: vaadin init --preset <preset> my-project

You can add Collaboration Engine to your project with the collaboration preset You can also use the empty preset for a project with no menu and an empty view.

What other presets would you like to see included?

What's next?

We’d like to hear it from you. We’re planning to make the CLI more feature-rich by adding convenience functions to it, such as a Vaadin version updater, migration/conversion scripts, the ability to add views to a project (similar to start.vaadin.com), utilities for theme management, license installation for Vaadin Pro/Prime commercial features, and more. 

However, we’re also asking for input from our users.

Do you use the CLI? What do you think of it? What’s missing? Let us know by commenting below or discussing it in our Discord community!

Mikael Sukoinen
Mikael Sukoinen
Mikael has a passion for writing text, code and music. He’s currently utilising his skills to explain difficult concepts in plain language at Vaadin Ltd.
Other posts by Mikael Sukoinen