Mount Rack Apps

Jets Routing supports mounting Rack applications. Example:


Jets.application.routes.draw do
  mount GrapeApp, at: 'grape'     # app/racks/grape_app
  mount SinatraApp, at: 'sinatra' # app/racks/sinatra_app
  mount RackApp, at: 'rack'  # app/racks/rack_app

Many Ruby Web frameworks are Rack compatible like Sinatra, Grape, Padrino, Hanami, and more. The mount ability allows you to run them on serverless with minimal effort.

Note: The Rack apps do not have reside in the app/racks folder. They only need to be in a folder that is autoloaded.

Mount Hash Notation

You can also use the hash notation to mount apps.


Jets.application.routes.draw do
  mount RackApp => 'rack'
  # mount RackApp, at: 'rack' # same thing


For an example project demonstrating the use of mount, check out rubyonjets/jets-routes-mount.

Gemfile Dependencies

When you mount a Rack app, you must also remember to add the its dependencies to your Gemfile. For example, if you are mounting a Sinatra app, then add the sinatra gem to Gemfile:

gem "sintara"

Mount at Root

To mount at the homepage root use an empty string for the at option. Example:

Jets.application.routes.draw do
  mount GrapeApp, at: '' # app/racks/grape_app

Custom Domain

When you deploy your application, API Gateway will add the stage name to the path. Here’s an example with the dev stage:

For Jets apps, the url helpers will add the stage name as necessary. Other frameworks do not have url helpers that account for API Gateway stage names. Applications usually referred to links by their document root url. For example, <a href=/posts>Posts</a>. So you’ll end up with this: # doesnt work

Instead of: # works

A quick way to fix this is use a Custom Domain. Custom domain urls not have a stage name appended and will look something like this: # works

General Recommendation

For lightweight frameworks like Sinatra and Grape mounting them is recommended. For heavier frameworks like Rails, mounting will not work due to name collisions.