Breezy
main
main
  • README
  • Code of conduct
  • Contributing Guide
  • Changelog
  • Security Policy
  • docs
    • configuration
    • Cross cutting concerns
    • deferments
    • Demo Application
    • Digging
    • Overview
    • Installation
    • NavigationContext
    • The page response
    • Rails utils
    • The store shape
    • Requests
    • Tutorial
    • The return of Rails UJS
    • recipes
      • Infinite scroll
      • Modals
      • progress-bar
      • Shopping cart
      • SPA (Single Page Application) Pagination
      • Server-Side Rendering
      • Replicating Turbo behavior
      • Usage with vite
    • Modules
      • Functions
      • Functions
      • index
      • types.actions
      • types
      • Interfaces
Powered by GitBook
On this page

Was this helpful?

  1. docs
  2. recipes

Replicating Turbo behavior

PreviousServer-Side RenderingNextUsage with vite

Last updated 4 months ago

Was this helpful?

With data-sg-visit, Superglue will always wait for a response before a navigation transition. Turbo's behavior is to transition first if possible while waiting for the response. To replicate this behavior:

In your application_visit.js file:


+ import { urlToPageKey } from '@thoughtbot/superglue'

const appVisit = (...args) => {

  const pageKey = urlToPageKey(args[0])
+ // attempt to navigate first
+ ref.current?.navigateTo(pageKey)

  return store
    .dispatch(visit(...args))
    ....

This is different from which controls what happens when the browser's history object pops.

restore strategy