Polling & Query Options

useActionQuery v1.1.0 features: refetchInterval, refetchOnFocus, enabled, transform

refetchInterval (auto-refresh every 2s)

Server time updates automatically every 2 seconds via polling.

Server time: 2026-11-27T18:26:35.895Z

Timestamp: 1795803995895

import { currentTime } from '#actions'

const { data } = useActionQuery(currentTime, undefined, {
  refetchInterval: 2000,
})

refetchOnFocus

Switch to another tab and come back — the todo list will refresh automatically.

2 todo(s) loaded — last refreshed when tab gained focus

Learn NuxtDone
Build appPending
import { listTodos } from '#actions'

const { data } = useActionQuery(listTodos, undefined, {
  refetchOnFocus: true,
})

enabled (toggle fetching)

Toggle the switch to enable/disable fetching. Data only loads when enabled is true.

enabled: false
Fetched 2 todo(s)
const fetchEnabled = ref(false)

const { data } = useActionQuery(listTodos, undefined, {
  enabled: fetchEnabled,
})

transform

Transform the response before it reaches the template. Here we reverse the order and add an index.

#1Set up CI/CD
#2Deploy to production
#3Write tests
#4Build app
#5Learn Nuxt
const { data } = useActionQuery(searchTodos, () => ({ q: '' }), {
  transform: (result) =>
    result.items.reverse().map((item, i) => ({
      ...item,
      index: i + 1,
    })),
})