---
title: "getCspNonce"
source: "https://github.com/remix-run/remix/blob/remix@3.2.0/packages/csp-middleware/src/lib/nonce.ts#L19"
---

# getCspNonce

## Summary

Gets the CSP nonce for authored script and style tags or custom rendering.
Internal frame requests use the enclosing document's nonce. Reading it does not generate one.

## Signature

```ts
function getCspNonce(context: RequestContext<AnyParams, ContextEntries>): string | undefined

```

## Example

```ts
<script src="/app.js" nonce={getCspNonce(context)} />
```

## Parameters

### `context`

Current request context.

## Returns

The nonce, or undefined when no nonce has been established.