/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-nonce-attribute-499828ea2804-nonce-attribute-s0232-c0002.md

`nonce` attribute (3) - hono-docs

nonce attribute (3) Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt nonce attribute Summary If yo...

nonce attribute (3)

Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#nonce-attribute

Summary

If you want to generate the nonce value yourself, you can also specify a function as the following: ```tsx const app = new Hono () const myNonceGenerator: ContentSecurityPolicyOptionHandler = (c) => { // This function is called on every...

Content

If you want to generate the nonce value yourself, you can also specify a function as the following:

const app = new Hono<{
  Variables: { myNonce: string }
}>()

const myNonceGenerator: ContentSecurityPolicyOptionHandler = (c) => {
  // This function is called on every request.
  const nonce = Math.random().toString(36).slice(2)
  c.set('myNonce', nonce)
  return `'nonce-${nonce}'`
}

app.get(
  '*',
  secureHeaders({
    contentSecurityPolicy: {
      scriptSrc: [myNonceGenerator, 'https://allowed1.example.com'],
    },
  })
)

app.get('/', (c) => {
  return c.html(
    <html>
      <body>
        {/** contents */}
        <script src='/js/client.js' nonce={c.get('myNonce')} />
      </body>
    </html>
  )
})
Kinic Wiki
Loading knowledge node
Details

Identity

database
db_23dhmsxlhukv
database_id
db_23dhmsxlhukv
path
/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-nonce-attribute-499828ea2804-nonce-attribute-s0232-c0002.md
kind
directory
role
markdown_note
children
0

Metadata

created_at
virtual
updated_at
virtual
etag
virtual
metadata_json
{}

Lint Hints

No lightweight warnings.

Outgoing Links

No outgoing links indexed.

Incoming Links

Select a file node to inspect backlinks.

Raw Source

No raw source path inferred.