> Markdown version of [Build for Production](https://vaadin.com/docs/latest/building-apps/production/build). Section index: [llms.txt](https://vaadin.com/docs/latest/building-apps/llms.txt)

# Build for Production

When you start a Vaadin application from your IDE, it runs in development mode, with live reload and other development tools. A production build creates an executable JAR that runs in production mode instead. It serves an optimized frontend bundle, and leaves the development tools out.

To build and start the application, run:

```terminal
./mvnw clean package
java -jar target/*.jar
```

Then look for this line in the log:

```
Vaadin is running in production mode.
```

## <a id="what-the-build-does"></a>What the Build Does

The `package` phase compiles the application and runs its tests, so a failing test stops the build. The `build-frontend` goal of the Vaadin Maven plugin then prepares the frontend bundle, and marks the build for production mode. Finally, Spring Boot packages everything into a single JAR in the `target` directory.

Projects from [`start.vaadin.com`](https://start.vaadin.com) are set up for this. If you created the `pom.xml` yourself, add the `build-frontend` goal, and make the `vaadin-dev` dependency optional, so that the JAR doesn’t include the development tools. See [Enabling Production Builds](https://vaadin.com/docs/latest/flow/production/production-build.md#enabling-production-builds) and [Excluding Development Server Module](https://vaadin.com/docs/latest/flow/production/production-build.md#excluding-development-server-module).

If the log says `Vaadin is running in DEVELOPMENT mode` instead, or the application fails to start, see [Troubleshooting](https://vaadin.com/docs/latest/flow/production/troubleshooting.md).

## <a id="when-the-build-needs-node-js"></a>When the Build Needs Node.js

A Vaadin application needs a frontend bundle: the JavaScript and CSS of the UI components, and of any frontend code that the application adds. The build provides it in one of two ways:

- **A pre-compiled bundle.** If the application uses only Vaadin’s UI components and themes, and loads its own stylesheets with `@StyleSheet`, the build uses a bundle that comes with Vaadin. It doesn’t need Node.js, and the build log says `A production mode bundle build is not needed`.

- **An application-specific bundle.** If the application adds frontend code of its own — for example, an npm package, a JavaScript module, or an add-on with frontend code — the build runs npm and Vite to create a bundle for it. This needs Node.js and takes longer. The build log says `A production mode bundle build is needed`, and the line before it gives the reason.

The [Production Build](https://vaadin.com/docs/latest/flow/production/production-build.md) reference lists everything that requires an application-specific bundle.

An application-specific bundle is also written to `src/main/bundles/prod.bundle`. Commit this file. The next build reuses it, and doesn’t run npm or Vite at all, as long as the frontend code hasn’t changed. When the frontend code changes, the build notices it, and creates a new bundle. Commit that one, too.

## <a id="when-the-build-needs-a-license-key"></a>When the Build Needs a License Key

If the application uses a commercial feature, the production build checks that you have a license for it. On a machine without a license key, such as a fresh build server, the build fails with the following message, followed by a list of the commercial features it found:

```
Commercial features require a subscription.
```

On your development machine, you get the key by logging in to your Vaadin account, as described in [License Validation & Troubleshooting](https://vaadin.com/docs/latest/flow/configuration/licenses.md). To give the key to a build server, see [Build on CI](https://vaadin.com/docs/latest/building-apps/production/ci.md). To find out which features are commercial, see [Licensing, Support & Maintenance](https://vaadin.com/docs/latest/building-apps/architecture/licensing-and-maintenance.md).

## <a id="next-steps"></a>Next Steps

The JAR contains the configuration that’s in `src/main/resources/application.properties`. Production needs different settings and secrets, which shouldn’t be in the source code. [Configure the Application](https://vaadin.com/docs/latest/building-apps/production/configure.md) shows how to provide them.
