reqRef, reqSsrRef

You can define server-side refs that are reset on each request.

reqRef declares a normal ref with one key difference. It resets the value of this ref on each request. You can find out more information here.

You do not need a reqRef if you are using an ssrRef within a component setup function as it will be automatically tied to the per-request state.
You should take especial care because of the danger of shared state when using refs in this way.


import { reqRef } from '@nuxtjs/composition-api'

export const user = reqRef(null)

export const fetchUser = async () => {
    const r = await fetch('')
    user.value = await r.json()