# Turbo
> Part of the Hotwire stack, Turbo speeds up Rails web applications by replacing full page loads with targeted HTML swaps — no JSON APIs, no custom JavaScript required.

## What is Turbo?

Turbo is a JavaScript library that is part of [Hotwire](https://hotwired.dev/), the default frontend stack for Ruby on Rails (introduced in Rails 7). It lets you build fast, interactive web applications by sending HTML over the wire instead of JSON — which means you can stay in Ruby and avoid writing client-side data-fetching code.

Turbo is split into three components: Drive, Frames, and Streams.

## Turbo Drive

Turbo Drive intercepts link clicks and form submissions, fetches the response in the background, and swaps only the `<body>` of the page. This makes navigation feel instant without a full page reload.

```html
<!-- Nothing special needed. Turbo Drive is on by default. -->
<a href="/dashboard">Go to Dashboard</a>
```

To opt out of Turbo Drive on a specific link:

```html
<a href="/legacy-page" data-turbo="false">Legacy page</a>
```

## Turbo Frames

Turbo Frames let you scope navigation and form submissions to a specific portion of the page. Only the matching frame is replaced when the response comes back.

```html
<!-- On the current page -->
<turbo-frame id="product-details">
  <a href="/products/42">Load product</a>
</turbo-frame>

<!-- On /products/42, Turbo finds the matching frame and swaps it in -->
<turbo-frame id="product-details">
  <h2>Product name</h2>
  <p>Description here.</p>
</turbo-frame>
```

## Turbo Streams

Turbo Streams deliver server-side updates over WebSockets (via Action Cable) or as the response to form submissions. They let you append, prepend, replace, update, or remove DOM elements from anywhere on the page.

```erb
<!-- app/views/messages/create.turbo_stream.erb -->
<%= turbo_stream.append "messages" do %>
  <%= render @message %>
<% end %>
```

## Why it matters for Rails developers

Before Turbo (and its predecessor Turbolinks), making a Rails app feel fast usually meant reaching for React, Vue, or another SPA framework — with all the API layer complexity that entails. Turbo gives you most of that responsiveness while keeping your logic in Ruby and your templates in ERB.

It's not a replacement for every frontend framework use case, but for most CRUD-heavy Rails apps, Turbo handles 80% of the interactivity without a line of custom JavaScript.
