Skip to content


Routing (vapor/routing) is a small framework for routing things like HTTP requests. It lets you register and lookup routes in a router using nested, dynamic path components.

For example, the routing package can help you route a request like the following and collect the values of the dynamic components.



This package is included with Vapor and exported by default. You will have access to all Routing APIs when you import Vapor.


If you use Vapor, most of Routing's APIs will be wrapped by more convenient methods. See Getting Started → Routing for more information.

import Vapor


The Routing package is lightweight, pure-Swift, and has very few dependencies. This means it can be used as a routing framework for any Swift project—even one not using Vapor.

To include it in your package, add the following to your Package.swift file.

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "Project",
    dependencies: [
        .package(url: "", from: "3.0.0"),
    targets: [
      .target(name: "Project", dependencies: ["Routing", ... ])

Use import Routing to access the APIs.


Some of this guide may contain Vapor-specific APIs, however most of it should be applicable to the Routing package in general. Visit the API Docs for Routing-specific API info.