Last active
July 9, 2025 18:38
-
-
Save milksense/1c3d5d492ba12a8ac341f56761136405 to your computer and use it in GitHub Desktop.
Svelte 5 `isMac` hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { browser } from "$app/environment" | |
export function useIsMac(): { readonly current: boolean } { | |
const isMac = $derived(browser | |
? "userAgentData" in navigator | |
? navigator.userAgentData?.platform.includes("macOS") | |
: navigator?.platform.includes("Mac") | |
: false | |
) | |
return { | |
get current(): boolean { | |
return isMac | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment