developing-with-turbo-basics

2
0
Source

Basics of developing with Turbo in web applications. Activate when working on projects that utilize Turbo for enhancing user experience through partial page updates, real-time interactions, and seamless navigation without full page reloads.

Install

mkdir -p .claude/skills/developing-with-turbo-basics && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4137" && unzip -o skill.zip -d .claude/skills/developing-with-turbo-basics && rm skill.zip

Installs to .claude/skills/developing-with-turbo-basics

About this skill

Turbo Laravel Basics

Turbo Laravel is a package that integrates Turbo, a set of technologies for building modern web applications, with the Laravel framework. Turbo enhances user experience by enabling partial page updates, real-time interactions, and seamless navigation without full page reloads and with minimal JavaScript.

Philosophy: HTML Over the Wire

Hotwire (HTML Over the Wire) sends HTML instead of JSON from the server, letting the server handle rendering while keeping the browser's job simple. It combines four techniques:

  1. Turbo Drive — Accelerates links and forms by replacing the <body> without full page loads.
  2. Turbo Frames — Decomposes pages into independent segments that scope navigation and can lazy-load.
  3. Turbo Streams — Delivers partial page changes over WebSocket, SSE, or in response to form submissions using eight actions (append, prepend, replace, update, remove, before, after, refresh).
  4. Stimulus — A modest JavaScript framework for the HTML you already have, connecting behavior via data-controller, data-action, and data-target attributes.

Turbo Laravel provides the server-side tooling (Blade components, helpers, broadcasting, and testing utilities) to make these techniques work seamlessly with Laravel.

Turbo Drive

Turbo Drive intercepts all clicks on <a href> links to the same domain and all form submissions, turning them into fetch requests. It replaces the <body> and merges the <head>, keeping the JavaScript window and document objects persistent across navigations. This gives SPA-like speed without client-side routing.

Same deal with forms — their submissions become fetch requests and Turbo Drive follows the redirect and renders the HTML response.

IMPORTANT: Activate the developing-with-turbo-drive skill when starting out working on a feature.

Turbo Frames

Turbo Frames let you place independent segments inside <turbo-frame> elements that scope their navigation. All interaction within a frame (clicking links, submitting forms) happens within that frame, keeping the rest of the page intact. Frames can also lazy-load their content via a src attribute.

@verbatim

<code-snippet name="Turbo Frame" lang="blade"> <x-turbo::frame :id="$post"> <h3>{{ $post->title }}</h3> <a href="{{ route('posts.edit', $post) }}">Edit</a> </x-turbo::frame> </code-snippet>

@endverbatim

Benefits: independent caching, parallelized execution, and mobile-ready segments.

IMPORTANT: Activate the developing-with-turbo-frames skill when working with Turbo Frames.

Turbo Streams

Turbo Streams let you change any part of the page using a <turbo-stream> element with eight actions: append, prepend, replace, update, remove, before, after, and refresh. They work both as HTTP responses and over WebSocket broadcasts.

@verbatim

<code-snippet name="Turbo Stream" lang="blade"> <x-turbo::stream action="append" target="messages"> <div id="message_1">My new message!</div> </x-turbo::stream> </code-snippet>

@endverbatim

IMPORTANT: Activate the developing-with-turbo-streams skill when working with Turbo Streams.

Blade Components

@verbatim

  • <x-turbo::frame :id="$model"> — Renders a <turbo-frame> with auto DOM ID resolution. :id accepts a string, model instance, or [$model, 'prefix'] array.
  • <x-turbo::stream action="append" :target="$model"> — Renders a <turbo-stream> element. Omits the <template> wrapper for brevity.
  • <x-turbo::stream-from :source="$model" /> — Listens for broadcasts on the model's channel (private by default, add type="public" for public).
  • <x-turbo::refreshes-with method="morph" scroll="preserve" /> — Configures page refresh behavior (morphing and scroll preservation).
  • <x-turbo::exempts-page-from-cache /> — Adds <meta name="turbo-cache-control" content="no-cache">.
  • <x-turbo::exempts-page-from-preview /> — Adds <meta name="turbo-cache-control" content="no-preview">.
  • <x-turbo::page-requires-reload /> — Adds <meta name="turbo-visit-control" content="reload">.
  • <x-turbo::page-view-transition /> — Adds <meta name="view-transition" content="same-origin">.

@endverbatim

Helpers & Directives

@verbatim

  • DOM IDs: dom_id($model) returns e.g. "post_1", dom_id($model, 'edit') returns "edit_post_1". Blade directive: @domid($model, 'prefix').
  • DOM classes: dom_class($model) returns e.g. "post", dom_class($model, 'admin') returns "admin_post". Blade directive: @domclass($model, 'prefix').
  • Channel: @channel($model) outputs the model's broadcast channel name.
  • Conditional: @hotwirenative / @endhotwirenative shows content only for Hotwire Native visits. Also: @unlesshotwirenative, @turbonative / @endturbonative.

@endverbatim

Request Macros

@verbatim

<code-snippet name="Request macros" lang="php"> // Check if the request accepts Turbo Stream responses $request->wantsTurboStream(); // bool

// Check if the request came from a Turbo Frame (optionally a specific one) $request->wasFromTurboFrame(); // bool $request->wasFromTurboFrame(dom_id($post, 'create_comment')); // bool

// Check if the request came from a Hotwire Native client $request->wasFromHotwireNative(); // bool </code-snippet>

@endverbatim

Response Helpers

@verbatim

<code-snippet name="Response helpers" lang="php"> // Return a Turbo Stream response for a model (auto-detects action from context) return turbo_stream($model); return turbo_stream($model, 'prepend');

// Return a fluent Turbo Stream builder return turbo_stream()->append('posts', view('posts._post', ['post' => $post]));

// Return multiple streams return turbo_stream([ turbo_stream()->append('posts', view('posts._post', ['post' => $post])), turbo_stream()->update('post_count', view('posts._count', ['count' => $count])), ]);

// Return a Turbo Stream view (renders a Blade view with the Turbo Stream content type) return turbo_stream_view('posts.turbo.created', ['post' => $post]); </code-snippet>

@endverbatim

Form Handling

Laravel resource conventions auto-redirect on validation errors:

  • *.store*.create, *.update*.edit, *.destroy*.delete

Performance & UX

@verbatim

  • Preserve elements during navigation: <div id="flash" data-turbo-permanent>...</div>
  • Disable preloading on specific links: <a data-turbo-preload="false">...</a>
  • Disable Turbo on specific elements: <a data-turbo="false">...</a>
  • Re-enable Turbo within a disabled container: <a data-turbo="true">...</a>

@endverbatim

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318399

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

340397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

452339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.