Skip to content

Hello, world

Now that you've installed Vapor, let's create your first Vapor app! This guide will take you step by step through creating a new project, building, and running it.

New Project

The first step is to create a new Vapor project on your computer. For this guide, we will call the project Hello.

Open up your terminal, and use Vapor Toolbox's new command.

vapor new Hello

Once that finishes, change into the newly created directory.

cd Hello

Generate Xcode Project

Let's now use the Vapor Toolbox's xcode command to generate an Xcode project. This will allow us to build and run our app from inside of Xcode, just like an iOS app.

vapor xcode

The toolbox will ask you if you'd like to open Xcode automatically, select yes.

Build & Run

You should now have Xcode open and running. Select the run scheme from the scheme menu and My Mac as the deployment target, then click the play button.

You should see the terminal pop up at the bottom of the screen.

Server starting on http://localhost:8080

Visit Localhost

Open your web browser, and visit localhost:8080/hello →

You should see the following page.

Hello, world!

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

Comments