---
title: "#62: JLRoutes 🔗"
url: https://littlebitesofcocoa.com/62-jlroutes
author: Jake Marsh
date: 2015-08-18
published: 2015-08-18
topics: ["Libraries"]
description: "JLRoutes is a library from Joel Levin that makes it very easy to manage \"routes\" for URL schemes in an app. It's common to need to \"deep link\" in to an app."
---

# #62: JLRoutes 🔗

By Jake Marsh, August 18, 2015. HTML: https://littlebitesofcocoa.com/62-jlroutes

[JLRoutes](http://git.io/routes) is a library from [Joel Levin](https://github.com/joeldev) that makes it very easy to manage "routes" for **URL schemes** in an app. It's common to need to "deep link" in to an app. Other apps can use these to open your app to a specific spot, or we can use them within our own app such as when the user opens a push notification. Let's take a look.

First we'll add a new **URL Type** for our app. In Xcode, we'll go to our **project**, then **target settings**, then to the **Info** tab, and finally to the **URL Types** section.

<img src="https://media.littlebitesofcocoa.com/bite-assets/062-jlroutes-url-type.png" style="max-width: 414px;" />

Neat, now URLs in the form of `spaceships://something` will open our app! Now let's add our first route.

These can added anywhere, but it's best to set them up early, when the app has first launched.

``` swift
JLRoutes.addRoute("/spaceships/:id") { (params: [NSObject : AnyObject]!) -> Bool in
  guard let spaceshipID = params["id"] as? String else { return false }

  let vc = SpaceshipViewController()      
  vc.spaceshipID = spaceshipID

  self.currentNavigationController().pushViewController(vc, animated: true)

  return true
}
```

A few things to note here. First notice the `:id` portion of the route path. This lets us easily extract out portions of the route from the `params` dictionary.

Also note how we use guard and return false if we can't handle the URL for some reason.

In addition, **JLRoutes** has support for wildcard matching as well as route namespaces.

More info about **JLRoutes** can be found at [git.io/routes](http://git.io/routes)
