Skip to content

Hello, world

This guide will take you step by step through creating a new Vapor project, building it, and running the server.

If you have not yet installed Swift or Vapor Toolbox, check out the install section.

New Project

The first step is to create a new Vapor project on your computer. Open up your terminal and use Toolbox's new project command. This will create a new folder in the current directory containing the project.

vapor new hello -n

Tip

The -n flag gives you a bare bones template by automatically answering no to all questions.

Once the command finishes, change into the newly created folder and open Xcode.

cd hello
open Package.swift

Xcode Dependencies

You should now have Xcode open. It will automatically begin downloading Swift Package Manager dependencies.

At the top of the window, to the right of the Play and Stop buttons, click on your project name to select the project's Scheme, and select an appropriate run target—most likely, "My Mac".

Build & Run

Once the Swift Package Manager dependencies have finished downloading, click the play button to build and run your project.

You should see the Console pop up at the bottom of the Xcode window.

[ INFO ] Server starting on http://127.0.0.1:8080

Visit Localhost

Open your web browser, and visit localhost:8080/hello or http://127.0.0.1:8080

You should see the following page.

Hello, world!

Congratulations on creating, building, and running your first Vapor app! 🎉