Skip to content

Turbolinks

A small JavaScript library that makes page-to-page navigation feel faster without a frontend framework. Archiv

Stars
12.6k
Forks
598
Licence
MIT
Language
TypeScript
Last update
5.2 years ago
Type
Library

This repository is archived and no longer maintained.

What it is

Turbolinks is a JavaScript library for web applications that intercepts clicks on same-domain links, fetches the next page in the background, and swaps in its body without a full browser page load. Your server still returns ordinary HTML pages, so you get faster navigation without building a client-side single-page app. The project is archived and no longer actively developed; its README says it has been superseded by Turbo, part of the Hotwire family.

  • Make clicks between pages in a server-rendered site load without a full page refresh
  • Show a cached preview of a page immediately while the new response loads
  • Use the Back and Reload buttons normally while navigating between pages
  • Start a navigation from code with Turbolinks.visit(location)

Great for

  • Existing Ruby on Rails apps that want faster navigation with minimal changes
  • Teams with server-rendered HTML who want SPA-like speed without a frontend framework
  • Developers maintaining an existing Turbolinks application

Not ideal for

  • New projects: the README says Turbolinks is no longer under active development and points to Turbo instead
  • Apps that need the library to receive future fixes or browser compatibility updates, since the project is archived
  • Users who need JavaScript that runs only on the initial load, because the body is replaced on every navigation

How to get it

  1. 1

    Install with a package manager

    Install the npm package

    npm install --save turbolinks

    Add the Rails gem (version 5) to your Gemfile

    gem 'turbolinks', '~> 5.2.0'

    Install gems

    bundle install
  2. 2

    Run it

    • Install the package with npm or add the Rails gem as described in the README.
    • Load Turbolinks through a script tag or bundle, which initializes it automatically; for CommonJS or AMD modules, call start().
    • Navigate between pages on your site and confirm the page body swaps without a full reload.
  3. 3

    Get the most out of it

    • Use data-turbolinks-action="replace" on a link to replace the current history entry instead of adding one.
    • Use Turbolinks.visit(location, { action: "replace" }) to navigate programmatically with the replace action.
    • Disable Turbolinks on specific links when a full page load is needed (see the README section on disabling Turbolinks on specific links).
    • Use the README's guidance on caching and the Turbolinks.clearCache API to control cached previews.
    • For new projects, consider the Turbo framework that the README recommends instead.

Downloads

Strengths

  • Works with plain server-rendered HTML, with no need to return JSON or partial fragments
  • Keeps Back and Reload buttons and search-engine friendliness, according to the README
  • Has iOS and Android adapters for hybrid apps with native navigation controls

Trade-offs

  • Archived and no longer actively developed, so it will not receive new development
  • Depends on the HTML5 History API and requestAnimationFrame, so older browsers fall back to standard navigation

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.