[Violation] Permissions policy violation: unload is not allowed in this document. #91378
Replies: 2 comments 2 replies
|
I can't reproduce right now. I have Chrome 146. Do I need to enable an additional browser flag? I used a 16.1.6, and then I navigate away window.location.href... That being said, I do think we have done this migration to If this is happening in the version 14 range, then it is worth noting that, version 14 range is unsupported: https://nextjs.org/support-policy#unsupported-versions - since October 2025. |
1 reply
|
Sorry, my mistake. I didn't read carefully. The issue was caused by my browser extension. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
[Violation] Permissions policy violation: unload is not allowed in this document.
Description
When running a Next.js application in Chrome/Edge browsers, the console shows a permissions policy violation warning:
[Violation] Permissions policy violation: unload is not allowed in this document.Steps to Reproduce
npx create-next-app@latestnpm run devhttp://localhost:3000in Chrome/EdgeExpected behavior: No permissions policy violations in console.
Actual behavior: Console shows:
[Violation] Permissions policy violation: unload is not allowed in this document.Code Example
The error appears without any custom
unloadevent listeners. However, it can be reproduced by adding:Root Cause
Chrome/Edge browsers have implemented stricter Permissions Policies to improve performance and security. The
unloadevent is being deprecated because it prevents pages from using the back/forward cache (bfcache), which significantly impacts user experience during navigation.The default Permissions Policy in modern browsers restricts
unloadunless explicitly allowed.Environment
Possible Solutions
1. Replace
unloadwithpagehide(Recommended)2. Configure Permissions Policy in Next.js
3. Use Middleware (Next.js 12+)
Related Issues
unload: https://developer.chrome.com/blog/page-lifecycle-api/#the-unload-eventAdditional Context
unloadlisteners are added, suggesting Next.js internals or third-party libraries might be using it.pagehideinstead ofunloadenables bfcache, improving navigation performance by up to 10x.visibilitychange+sendBeaconinstead ofunload.Workaround Status
unloadusage in codebasepagehide/pageshow)Request
unloadevents?pagehideoverunloadunloadLabels:
bug,browser-compatibility,performance,documentationAdditional information
No response
Example
No response
All reactions