---
title: Geistdocs Provider
description: The root provider component that handles notifications, search and analytics
type: reference
summary: The root provider component that wraps your application to handle toast notifications, search, and analytics.
url: /docs/provider
source: apps/template/content/docs/provider.mdx
prerequisites:
  - /docs/getting-started
related:
  - /docs/configuration
---

# Geistdocs Provider

The `GeistdocsProvider` wraps the root of your application with package-managed UI state. It connects theme, search, AI chat, notifications, and optional analytics to the rest of your Geistdocs site.

  Review my Geistdocs provider setup. Check that the root layout wraps the app with `GeistdocsProvider`, that config is passed correctly, and that analytics, search, theme, and Ask AI behavior are wired safely.

## What it does

The provider handles these behaviors:

1. **Toast notifications**: Provides a global notification system for user feedback.
2. **Analytics**: Integrates Vercel Analytics and Speed Insights when the local adapter includes them.
3. **Search**: Configures the search dialog and connects it to your search API.
4. **Ask AI**: Provides the client state used by the chat sidebar and page actions.

## Usage

Ensure your application is wrapped with the provider in your root layout:

```tsx title="app/layout.tsx"
import { GeistdocsProvider } from "@/components/geistdocs/provider";

const Layout = ({ children }: LayoutProps) => (
  <html lang="en">
    <body>
      <GeistdocsProvider>
        <Navbar />
        {children}
      </GeistdocsProvider>
    </body>
  </html>
);
```

The generated local adapter imports the package provider and passes your site config to it.

## Search scope

A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:

```tsx title="app/layout.tsx"
<GeistdocsProvider config={config} search={{ options: { tag: "v5" } }}>
```

The dialog sends it to your search route as `?tag=v5`, alongside the query. Read it from the request URL and filter results with it. Leave the option unset and the parameter is omitted, so the request is unchanged.

Pass the scope here rather than reading a header or a cookie in the route. The search client caches results per request URL for the lifetime of the page, so two scopes that produce the same URL share one cache entry, and the second reader is served the first reader's results.

> Note:
  `createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.

## AI Sidebar

When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.

The provider detects the screen size and chat state.

If Ask AI fails while rendering, its panel shows **Try again** and **Close** actions. The error remains scoped to the chat panel, so the documentation page and navigation stay available.

## Toast Notifications

The provider includes a global toast notification system. Use it anywhere in your app:

```tsx title="page.tsx"
import { toast } from "sonner";

toast.success("Changes saved");
toast.error("Something went wrong");
```

## Analytics

Vercel Analytics is automatically included and tracks:

- Page views
- Web Vitals
- User interactions
- Performance metrics

No configuration needed - it works automatically when deployed on Vercel.
