Inertia 3.9: pause polling in background tabs and detect back-button visits

Inertia 3.9 adds a background option for usePoll, a type field on the navigate event so you can refresh stale pages after the back button, and 3.9.1 ships two security hardening fixes. Here is what changed, with Vue 3 examples.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/inertia-3-9-background-polling-navigate-type.md
Inertia 3.9 adds a background option for usePoll, a type field on the navigate event so you can refresh stale pages after the back button, and 3.9.1 ships two security hardening fixes. Here is what changed, with Vue 3 examples.
Show the diff. Do not commit.

Next: Laravel and Vue translations

On this page · 10 sections
  1. Update to 3.9.1
  2. Pause polling in background tabs
  3. Before and after
  4. Which mode should you pick?
  5. Know how the user arrived: the navigate event type
  6. Refresh stale data after the back button
  7. Track real page views
  8. Security hardening in 3.9.1
  9. Other fixes worth knowing
  10. Upgrade notes
  11. Recap
  12. FAQ
  13. Next steps
  14. Sources

Your dashboard polls every 5 seconds, and so does every forgotten tab, all day long. And when users hit the back button, they see the data from ten minutes ago. Inertia 3.9 fixes both with one option and one event field.

TL;DR

  • 3.9.0 (October 9, 2026) adds background: 'pause' | 'throttle' | 'continue' to polling and a type field ('initial' | 'visit' | 'history') on the navigate event.
  • 3.9.1, out a few hours later, keeps the XSRF header on same-origin requests and gives every encrypted history entry its own IV.
  • No breaking changes and nothing to change in Laravel. Update to 3.9.1.

What you'll learn

  • Pausing usePoll in hidden tabs with background: 'pause'
  • Refreshing stale pages after the back button with the navigate event type
  • What the 3.9.1 security fixes change

Who it's for: Vue developers on Inertia 3

Applies to: @inertiajs/vue3 3.9.1 · inertia-laravel 3.5 · Vue 3.5

Update to 3.9.1#

Update in one line

bash
npm install @inertiajs/vue3@^3.9.1

That’s all. Nothing in 3.9 is a breaking change, and inertiajs/inertia-laravel 3.5 works as is.

Pause polling in background tabs#

Polling is the simplest way to keep a page fresh: an order status, a queue monitor, a list of notifications. Until now, Inertia had two modes when the user switched to another tab:

  • Default: keep polling, but only every 10th interval.
  • keepAlive: true: keep polling at the full speed.

There was no way to stop completely. A dashboard that polls every 5 seconds still sent a request every 50 seconds from every forgotten tab, all day long.

Before and after#

Until 3.9, stopping polling in hidden tabs meant wiring up visibilitychange yourself. Now it is one option:

3.8, then 3.9:

resources/js/pages/orders/index.vuevue
<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import { usePoll } from '@inertiajs/vue3'

const { start, stop } = usePoll(5000, { only: ['orders'] }, { autoStart: false })

const sync = () => (document.hidden ? stop() : start())

onMounted(() => {
    sync()
    document.addEventListener('visibilitychange', sync)
})

onUnmounted(() => document.removeEventListener('visibilitychange', sync))
</script>
resources/js/pages/orders/index.vuevue
<script setup lang="ts">
import { usePoll } from '@inertiajs/vue3'

usePoll(5000, { only: ['orders'] }, { background: 'pause' })
</script>

It is also smarter than the hand-written version. When the tab becomes visible again, Inertia sends a request right away only if one was due while the tab was hidden. Otherwise it waits for the rest of the current interval. So a user who flicks between tabs does not trigger a request on every switch.

The option has three values:

backgroundWhat happens in a hidden tab
'throttle' (default)Polls every 10th interval, same as before
'pause'Stops polling, resumes when the tab is visible
'continue'Keeps polling at the full interval

Heads up: keepAlive is deprecated

keepAlive: true still works, but it is now deprecated in favor of background: 'continue'. If you use it, this is a one-line change.

typescript
usePoll(2000, {}, { keepAlive: true }) 
usePoll(2000, {}, { background: 'continue' }) 

The same option works with router.poll() outside components:

typescript
import { router } from '@inertiajs/vue3'

const { stop } = router.poll(10_000, { only: ['stats'] }, { background: 'pause' })

On the Laravel side, pair polling with a partial reload so each request only computes the prop you need:

app/Http/Controllers/OrderController.phpphp
public function index(Request $request): Response
{
    return Inertia::render('orders/index', [
        'filters' => $request->only('status'),
        'orders' => fn () => OrderResource::collection(
            $request->user()->orders()->latest()->limit(20)->get()
        ),
    ]);
}

Tip: poll only what changes

Because orders is a closure, a poll with only: ['orders'] skips everything else.

Which mode should you pick?#

Use 'pause' for anything the user only cares about while looking at it: dashboards, lists, admin screens. Keep 'continue' for things that must keep running in the background, such as keeping a session alive or tracking a long job that should notify the user when it ends.

Inertia 3.9 also fixes a related bug: a poll created while the tab was already hidden used to run at full speed until the next visibility change. Now it respects the hidden state from the start.

Know how the user arrived: the navigate event type#

When the user presses the back button, Inertia restores the page from browser history. That is fast, but the props are the ones the page had when the user left it. An inbox that showed 3 unread messages ten minutes ago still shows 3, even if there are now 12.

Before 3.9, there was no public way to tell a history restore apart from a normal visit. Now the navigate event has a type:

typeWhen
'initial'First page load, including a browser reload
'visit'A normal Inertia visit (link click, router.visit, form submit)
'history'The page was restored with the back or forward button

Refresh stale data after the back button#

Register the listener once, for example in resources/js/app.ts:

resources/js/app.tstypescript
import { router } from '@inertiajs/vue3'

router.on('navigate', (event) => {
    if (event.detail.type === 'history') {
        router.reload({ only: ['messages'] })
    }
})

If only some pages need fresh data, check the component name so other pages are not reloaded for nothing:

typescript
const refreshOnBack: Record<string, string[]> = {
    'inbox/index': ['messages', 'unreadCount'],
    'orders/index': ['orders'],
}

router.on('navigate', ({ detail }) => {
    const only = refreshOnBack[detail.page.component]

    if (detail.type === 'history' && only) {
        router.reload({ only })
    }
})

The reload is a partial reload, so the user sees the restored page instantly and the fresh data arrives a moment later.

Track real page views#

The same field helps with analytics. You probably don’t want to count a back-button restore the same way as a new page view:

typescript
router.on('navigate', ({ detail }) => {
    analytics.track('page_view', {
        url: detail.page.url,
        restored: detail.type === 'history',
    })
})

Gotcha: coming back from another site

If the user goes back from a non-Inertia page (an external site, a file download page) and the browser restores your app, the type is also 'history', because the props come from the saved history state in that case too (from the pull request).

Security hardening in 3.9.1#

Two fixes, both automatic once you update:

  • The XSRF token stays on your own origin. Inertia’s built-in HTTP client sent the X-XSRF-TOKEN header on every request, including requests to other domains, for example a presigned S3 upload URL used with useHttp. Now the header is only added for same-origin URLs. If you really need it for another origin, add it yourself in an http.onRequest handler.
  • History encryption uses a fresh IV for every entry. If you use Inertia::encryptHistory(), entries used to share one AES-GCM IV per tab. Each entry now gets its own random IV. Entries saved by older versions can’t be decrypted anymore, so Inertia simply fetches those pages from the server again. Users won’t notice anything.

Heads up: update to 3.9.1, not 3.9.0

If your app sends requests to other domains with useHttp, this is the main reason to update today.

Other fixes worth knowing#

  • useRemember no longer restores state from an earlier page on a brand-new visit to the same component.
  • <InfiniteScroll> ignores responses that arrive after the component is gone, and no longer errors when unmounted right after its items change.
  • Clearing history (router.clearHistory()) now also flushes the prefetch cache, so no prefetched page with old data survives a logout.
  • history.replaceState quota errors (very large pages) are handled instead of crashing the visit.
  • The Vite plugin keeps source maps for your entry file.

Upgrade notes#

  • No breaking changes. Update to 3.9.1, not 3.9.0, to get the security fixes.
  • Search for keepAlive in resources/js and switch to background: 'continue' to avoid the deprecation.
  • Consider background: 'pause' on every usePoll that only matters while the page is visible. It is a free reduction in server load.
  • On Inertia 2? Version 2.3.29 was released the same day with the history encryption IV fix and the prefetch cache flush.

Recap#

  • usePoll(ms, reload, { background: 'pause' }) stops polling in hidden tabs and catches up only if a poll was due.
  • background is 'throttle' (default), 'pause' or 'continue'; keepAlive: true is deprecated.
  • navigate events now carry type: 'initial', 'visit' or 'history'. Reload stale props on 'history'.
  • 3.9.1 keeps the XSRF header on your own origin and uses a fresh IV per encrypted history entry.

FAQ#

How do I stop Inertia polling when the tab is hidden?

Pass { background: 'pause' } as the third argument to usePoll (or router.poll). It needs @inertiajs/vue3 3.9 or newer.

Is keepAlive removed in Inertia 3.9?

No, it still works but is deprecated. Replace keepAlive: true with background: 'continue'.

How can I detect a back-button visit in Inertia?

Listen to the navigate event and check event.detail.type === 'history'. Then call router.reload({ only: [...] }) to refresh stale props.

Do I need to change anything in Laravel for Inertia 3.9?

No. inertiajs/inertia-laravel 3.5 works as is; the changes are all in the client packages.

Is there a fix for Inertia 2 too?

Yes. Inertia 2.3.29, released the same day, has the history encryption IV fix and the prefetch cache flush.

Next steps#

Sources#

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.