Skip to main content
Version: 2.x

Installation

In this guide, we will learn how to get started with a new ZIO HTTP project.

Before we dive in, we should make sure that we have the following on our computer:

  • JDK 17 or higher
  • sbt (scalaVersion >= 2.12)

Manual Installation

To use ZIO HTTP, we should add the following dependencies in our project:

libraryDependencies += "dev.zio" %% "zio-http" % "3.0.1"

Using g8 Template

To set up a ZIO HTTP project using the provided g8 template we can run the following command on our terminal:

sbt new zio/zio-http.g8

This template includes the following plugins:

These dependencies in the g8 template were added to enable an efficient development process.

Hot-reload Changes (Watch Mode)

Sbt-revolver can watch application resources for change and automatically re-compile and then re-start the application under development. This provides a fast development-turnaround, the closest we can get to real hot-reloading.

We can start our application from sbt with the following command:

~reStart

Pressing enter will stop watching for changes, but not stop the application. We can use the following command to stop the application (shutdown hooks will not be executed):

reStop

In case we already have a sbt server running, i.e. to provide our IDE with BSP information, we should use sbtn instead of sbt to run ~reStart, this lets both sbt sessions share one server.

Formatting Source Code

Scalafmt will automatically format all source code and assert that all team members use consistent formatting.

Refactoring and Linting

Scalafix will mainly be used as a linting tool during everyday development, for example by removing unused dependencies or reporting errors for disabled features. Additionally, it can simplify upgrades of Scala versions and dependencies, by executing predefined migration paths.

SBT Native Packager

The sbt-native-packager plugin can package the application in the most popular formats, for example, Docker images, RPM packages, or graalVM native images.