# Skew protection

Skew protection handles mismatches in tabs running an older deployment after the server has moved to
a newer one. Without it, the old client can request
[route trees, segments](./routing/navigations.md), or [Server Functions](./server-functions.md) that
no longer match the server.

Rebask compares each response’s deployment id with the id embedded in the running client bundle.
By default, mismatches reload the current URL for user navigations and Server Functions, but are
ignored for [background prefetches](./routing/navigations.md#link).

## Handle mismatches

Use `useOnDeploymentMismatch` to customize mismatch handling:

```tsx
"use client"

import { useOnDeploymentMismatch } from "@rebask/core/deployment"

useOnDeploymentMismatch((event) => {
  // event.kind: "tree" | "segment" | "action"
  return "reload" // or "throw"
})
```

Returning nothing uses the default behavior: reload for user interactions and actions, ignore background prefetches.

## Detect new deployments

`useOnDeploymentUpdate` checks for a newer deployment when the tab becomes visible or at a
configured interval. It only calls your handler:

```tsx
"use client"

import { useOnDeploymentUpdate } from "@rebask/core/deployment"

useOnDeploymentUpdate(
  () => {
    // show a banner or reload
  },
  { interval: 60_000, checkOnVisible: true },
)
```

## Deployment id

Set a stable [`deploymentId`](../configuration.md#rebask-deploymentid) for each deployment.
