Skip to content

Commit d5dc46f

Browse files
authored
Add a new security docs page starting with CSP docs (#13356)
1 parent a6dbe72 commit d5dc46f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/how-to/security.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Security
3+
---
4+
5+
# Security
6+
7+
This is by no means a comprehensive guide, but React Router provides features to help address a few aspects under the _very large_ umbrella that is _Security_.
8+
9+
## `Content-Security-Policy`
10+
11+
If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML. This must be specified on any API that generates inline scripts, including:
12+
13+
- [`<Scripts nonce>`][scripts] (`root.tsx`)
14+
- [`<ScrollRestoration nonce>`][scrollrestoration] (`root.tsx`)
15+
- [`<ServerRouter nonce>`][serverrouter] (`entry.server.tsx`)
16+
- [`renderToPipeableStream(..., { nonce })`][renderToPipeableStream] (`entry.server.tsx`)
17+
- [`renderToReadableStream(..., { nonce })`][renderToReadableStream] (`entry.server.tsx`)
18+
19+
[csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP
20+
[nonce]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
21+
[renderToPipeableStream]: https://react.dev/reference/react-dom/server/renderToPipeableStream
22+
[renderToReadableStream]: https://react.dev/reference/react-dom/server/renderToReadableStream
23+
[scripts]: ../api/components/Scripts
24+
[scrollrestoration]: ../api/components/ScrollRestoration
25+
[serverrouter]: ../api/components/ServerRouter

0 commit comments

Comments
 (0)