> ## 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

# getWeaverseStudioCspDirectives

```typescript
getWeaverseStudioCspDirectives(request: string | URL | Request): WeaverseStudioCspDirectives
```

CSP directives for Weaverse Studio, for the request being rendered.

Returns `{}` for normal visitors: outside Studio the browser never contacts
Weaverse, so a theme's policy needs nothing extra. Inside Studio, the Studio
origin is allowed to embed the page and serve the bridge, and design mode
adds `'unsafe-eval'` because the bridge rebuilds schema `condition`
functions from strings.

The `weaverseHost` query is attacker-controllable, so it goes through the
same trust check that gates the bridge script: an untrusted host, or a
loopback host on a non-loopback storefront, returns `{}`, as does a relative
or malformed URL. Only `https://` hosts on `weaverse.io` or `weaverse.dev`
(or their subdomains) are trusted; without a `weaverseHost`, the default
Studio origin `https://studio.weaverse.io` is used. A self-hosted or staging
Studio on another domain is not trusted, so add that origin to your own
directives. Works in both report-only and enforcing policies.

React Router storefronts import it from `@weaverse/hydrogen/react-router`,
Next.js storefronts from `@weaverse/hydrogen/next/server`.

The example below needs `@shopify/hydrogen` 2026.10.3 or later, the first
release with `createContentSecurityPolicy`.

```ts
let csp = createContentSecurityPolicy({
  shop,
  directives: getWeaverseStudioCspDirectives(request),
})
```

Append Studio's sources to the theme's own instead of assigning them:
overwriting `scriptSrc` drops sources such as `'unsafe-inline'` inside
Studio.

```ts
import type { ContentSecurityPolicyDirectives } from '@shopify/hydrogen'
import { getWeaverseStudioCspDirectives } from '@weaverse/hydrogen/react-router'

export function getCspDirectives(request: Request): ContentSecurityPolicyDirectives {
  let directives: ContentSecurityPolicyDirectives = { ...THEME_DIRECTIVES }
  let studio = getWeaverseStudioCspDirectives(request)
  for (let key of Object.keys(studio) as (keyof typeof studio)[]) {
    directives[key] = [...(directives[key] ?? []), ...(studio[key] ?? [])]
  }
  return directives
}
```

## Parameters

**request** `string | URL | Request` *required*

## Returns

`WeaverseStudioCspDirectives`


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