We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e29ab79 commit 47749baCopy full SHA for 47749ba
packages/nuqs/src/debug.ts
@@ -1,9 +1,18 @@
1
// todo: Remove check for `next-usequerystate` in v2
2
-const enabled =
3
- (typeof localStorage === 'object' &&
4
- (localStorage.getItem('debug')?.includes('next-usequerystate') ||
5
- localStorage.getItem('debug')?.includes('nuqs'))) ||
6
- false
+let enabled = false
+
+try {
+ enabled =
+ (typeof localStorage === 'object' &&
7
+ (localStorage.getItem('debug')?.includes('next-usequerystate') ||
8
+ localStorage.getItem('debug')?.includes('nuqs'))) ||
9
+ false
10
+} catch (error) {
11
+ console.error(
12
+ '[nuqs]: debug mode is disabled (localStorage unavailable).',
13
+ error
14
+ )
15
+}
16
17
export function debug(message: string, ...args: any[]) {
18
if (!enabled) {
0 commit comments