> AI agents: this is one page of nextanalytica's docs. The full index for agents: https://nextanalytica.app/llms.txt

# TanStack Start cookie consent

> Wire a cookie banner in TanStack Start to analytics: count without cookies until the answer, and pass the saved answer on every page.

Updated: 2026-12-01

In TanStack Start, start the tag once in the browser and pass the saved answer with `consent()` from `@nextanalytica/tag`, in an effect in your root route. Until there's an answer, nextanalytica counts without cookies.

## How does it look?

```tsx title="src/routes/__root.tsx"
import { useEffect } from "react";
import nextanalytica, { consent } from "@nextanalytica/tag";

// inside your root route's component:
useEffect(() => {
  nextanalytica.init("na_…");
  const saved = localStorage.getItem("consent"); // "yes", "no" or null
  if (saved !== null) consent(saved === "yes");
}, []);
```

## What can you ask your agent?

- "How many visitors this week came before answering the banner?"

## Next steps

- [TanStack Start analytics](/docs/platforms/tanstack)
- [Cookieless counting and consent](/docs/tracking/cookieless-and-consent)

Canonical address: https://nextanalytica.app/docs/platforms/tanstack/consent
