> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# useStudioSelection

> Read what the merchant has selected in Weaverse Studio, a page item or a theme settings group, to open or highlight the matching UI.

# useStudioSelection

`useStudioSelection` returns what the merchant has selected in Weaverse Studio: a page item, or a theme settings group. Use it to reveal UI that is normally hidden while the merchant edits it, such as opening a newsletter popup when its settings group is selected.

## Import

```tsx theme={null}
import { useStudioSelection } from '@weaverse/hydrogen/react-router'
```

## Type

```typescript theme={null}
function useStudioSelection(): StudioSelection

type StudioSelection = {
  /** ID of the selected page item, or `null`. */
  selectedItemId: string | null
  /**
   * Name of the selected theme settings group, exactly as declared in the
   * schema `group` field, or `null`.
   */
  selectedThemeGroup: string | null
}
```

## Return Value

| Field | Type | Description |
| - | - | - |
| `selectedItemId` | `string \| null` | ID of the page item selected in Studio. |
| `selectedThemeGroup` | `string \| null` | Name of the selected theme settings group, matching the `group` field of your theme schema's `settings` exactly. |

An item and a theme group are never selected at the same time, so at most one field is non-null. Both are `null`:

* on the live storefront, outside Studio
* during server rendering and hydration
* outside a Weaverse root

The component re-renders whenever the selection changes.

## Setup

The selection store is mounted by [`withWeaverse`](https://weaverse.io/docs/api-reference/with-weaverse), which wraps your root `Layout`. No other setup is needed. If the root `Layout` isn't wrapped, the hook keeps returning the empty selection and the SDK logs a warning in Studio.

## Example

Open a popup while its settings group is selected in Studio's theme settings:

```tsx app/components/newsletter-popup.tsx theme={null}
import { useStudioSelection } from '@weaverse/hydrogen/react-router'

export function NewsletterPopup() {
  const { selectedThemeGroup } = useStudioSelection()
  // Matches `group: 'Newsletter Popup'` in the theme schema's settings
  const forceOpen = selectedThemeGroup === 'Newsletter Popup'

  // ...render the popup open when `forceOpen` is true
}
```

> [!NOTE]
>
> The Next.js adapter exports the same hook from `@weaverse/hydrogen/next`. There, `WeaverseNextRootProvider` mounts the store.

## Related

* [withWeaverse](https://weaverse.io/docs/api-reference/with-weaverse.md)
* [useWeaverse](https://weaverse.io/docs/api-reference/use-weaverse.md)
* [Design Mode](https://weaverse.io/docs/development-guide/design-mode.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.