Table of Contents
Chrome Automatic Fullscreen
How to enable fullscreen without a user gesture in Chrome
Use the AutomaticFullscreenAllowedForUrls policy to allow a site to enter fullscreen without a button click.
Requires Chrome 124+ for the policy and Chrome 128+ for the permission check below.
Enable the policy
Replace https://dashboard.example.com with your site's origin
Windows
Import this registry file for the current user. For all users, an administrator can use HKEY_LOCAL_MACHINE instead.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Google\Chrome\AutomaticFullscreenAllowedForUrls]
"1"="https://dashboard.example.com"
Add more origins as numbered string values (2, 3, etc.). Use an unused number when adding to an existing list.
Linux
Create /etc/opt/chrome/policies/managed/automatic-fullscreen.json with administrator permissions:
{
"AutomaticFullscreenAllowedForUrls": ["https://dashboard.example.com"]
}
Chromium packages may use a different policy directory.
macOS
Set AutomaticFullscreenAllowedForUrls to an array of allowed origins in the com.google.Chrome managed preferences domain using a configuration profile.
Verify the policy
- Open
chrome://policyin the Chrome profile that will run the app. - Select Reload policies.
- Check that
AutomaticFullscreenAllowedForUrlscontains your origin without errors. - Reload your site.
Usage
Check the permission before requesting fullscreen. Run this in the browser on an allowed origin.
async function enterAutomaticFullscreen() {
if (!document.fullscreenEnabled) return;
try {
const permission = await navigator.permissions.query({
name: "fullscreen",
allowWithoutGesture: true,
});
if (permission.state === "granted") {
await document.documentElement.requestFullscreen();
} else {
console.log("Automatic fullscreen is not allowed.");
}
} catch (error) {
console.error("Automatic fullscreen is unavailable:", error);
}
}
enterAutomaticFullscreen();
The query only checks permission; it does not show a prompt. Unsupported browsers can throw, which is why the check uses try/catch.
Without permission, call requestFullscreen() directly from a click handler instead. Users can still exit fullscreen with Escape.
References
Related snippets
Authorization with Pundit
Pundit is a simple and powerful authorization library that allows you to define policies for your application.
Authorization with ts-pattern
A simple example on how to use ts-pattern to authorize actions
Basic Permissions Class
A simple class to manage permissions
Drizzle ratelimit
Basic ratelimiting example with drizzle