isClientOutdated() · Nuxt Skew Protection · Nuxt SEO

-
-
-
-

[Sign In](https://nuxtseo.com/auth/github)

[Nuxt SEO on GitHub](https://github.com/harlan-zw/nuxt-seo)

Skew Protection

-
-
-
-
-
-
-
-
-
-

Search…```k`` /`

v1.1.1

- [Discord Support](https://discord.com/invite/275MBUBvgP)

### Nuxt API

-
-
-
-
-

### Nitro API

-
-

Nitro API

# isClientOutdated()

[Copy for LLMs](https://nuxtseo.com/docs/skew-protection/nitro-api/is-client-outdated.md)

**Type:** `function isClientOutdated(event: H3Event): boolean`

Returns `true` when the client's version cookie doesn't match the current `buildId`. Use this in server-side Nitro routes, middleware, and API handlers to detect outdated clients.

## [API](#api)

```
import { isClientOutdated } from 'nuxt-skew-protection/server'

function isClientOutdated(event: H3Event): boolean
```

### [Arguments](#arguments)

- `event: H3Event`: The H3 event object from the request handler.

### [Returns](#returns)

- `boolean`: `true` if the client version doesn't match the current buildId, `false` otherwise.

## [Examples](#examples)

### [Throwing an Error in API Route](#throwing-an-error-in-api-route)

```
// server/api/data.ts
import { isClientOutdated } from 'nuxt-skew-protection/server'

export default defineEventHandler(async (event) => {
  // Check if client is outdated
  if (isClientOutdated(event)) {
    throw createError({
      statusCode: 409,
      message: 'Client version outdated. Please refresh.'
    })
  }

  // Proceed with API logic
  const data = await fetchData()
  return data
})
```

### [Add Header in Middleware](#add-header-in-middleware)

```
// server/middleware/check-version.ts
import { isClientOutdated } from 'nuxt-skew-protection/server'

export default defineEventHandler((event) => {
  const path = event.path

  // Only check on API routes
  if (!path.startsWith('/api/')) {
    return
  }

  if (isClientOutdated(event)) {
    const userVersion = getSkewProtectionCookie(event)
    console.log(\`Outdated client detected: ${userVersion}\`)

    // Add header to inform client
    setResponseHeader(event, 'X-Client-Outdated', 'true')
  }
})
```

[Edit this page](https://github.com/nuxt-seo-pro/nuxt-skew-protection/edit/main/docs/content/3.nitro-api/2.is-client-outdated.md)

[Markdown For LLMs](https://nuxtseo.com/docs/skew-protection/nitro-api/is-client-outdated.md)

Did this page help you?

On this page

- [API](#api)
- [Examples](#examples)

[GitHub](https://github.com/harlan-zw/nuxt-seo) [ Discord](https://discord.com/invite/275MBUBvgP)

###

-
-

Modules

-
-
-
-
-
-
-
-
-

###

-
-
-

###

Nuxt

-
-
-
-
-

Vue

-
-
-
-
-
-
-
-

###

-
-
-
-
-
-
-
-
-
-

Copyright © 2023-2026 Harlan Wilton - [MIT License](https://github.com/harlan-zw/nuxt-seo/blob/main/license) · [mdream](https://mdream.dev)