Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Build Status Maintainability Test Coverage Gem Version License

JS From Routes generates path helpers and API methods from your Rails routes, allowing you to be more productive and prevent routing-related errors.

Since code generation is fully customizable it can be used in very diverse scenarios.

Why? πŸ€”

Path helpers in Rails make it easy to build URLs, while avoiding typos and mistakes.

With JS From Routes, it's possible the enjoy the same benefits in JS, and even more if using TypeScript.

Read more about it in the blog announcement.

Features ⚑️

  • πŸš€ Path and Request Helpers
  • πŸ” Serialization / Deserialization
  • βœ… Prevent Routing Errors
  • πŸ€– Automatic Generation
  • πŸ›  Customizable Generation
  • And more!

Documentation πŸ“–

Visit the documentation website to check out the guides and searchable configuration reference.

Installation πŸ’Ώ

For a one liner, you can use this template:

rails app:template LOCATION=''

Else, add this line to your application's Gemfile in the development group and execute bundle:

group :development, :test do
  gem 'js_from_routes'

Then, add the client library to your package.json:

npm install @js-from-routes/client # yarn add @js-from-routes/client

There are more client libraries available.

Getting Started πŸš€

The following is a short excerpt from the guide.

Specify the routes you want

Use the export attribute to determine which routes should be taken into account when generating JS.

Rails.application.routes.draw do
  resources :video_clips, export: true do
    get :download, on: :member

Use the path helpers in your JS application

Path helpers will be automatically generated when refreshing the page.

import { videoClips } from '~/api'

const video = await videoClips.get({ id: 'oHg5SJYRHA0' })

const downloadPath =

Check the documentation website for more information.

For a working example, check this repo.