© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
9 replies
davidmaxwaterman

Documentation for createClient doesn't match implementation? Bug in GoTrueClient.js?

In this doc 'with additional parameters' [1] is shows options
persistSession
persistSession
in an 'auth
 object inside the options. Due to my browser environment not having localStorage, I'm trying to disable attempts to use it, so I'm setting 
 object inside the options. Due to my browser environment not having localStorage, I'm trying to disable attempts to use it, so I'm setting 
persistSession
 to 
 to 
false
. However, that doesn't stop the implementation from trying to access localStorage. Setting 
. However, that doesn't stop the implementation from trying to access localStorage. Setting 
localStorage
 to null or something doesn't help either - it actually has to be set to something 'compatible', eg what I've ended up doing:
```
const supabase = globalThis.supabase.createClient(supabase_url, supabase_key, {
  persistSession: false,
  localStorage: {
    setItem: () => {},
    getItem: () => {},
    removeItem: () => {},
    clear: () => {},
  },
});
```

Doing the same in an 
 to null or something doesn't help either - it actually has to be set to something 'compatible', eg what I've ended up doing:
```
const supabase = globalThis.supabase.createClient(supabase_url, supabase_key, {
  persistSession: false,
  localStorage: {
    setItem: () => {},
    getItem: () => {},
    removeItem: () => {},
    clear: () => {},
  },
});
```

Doing the same in an 
auth
 property as indicated in the docs, doesn't help, because of this line:

https://github.com/supabase/gotrue-js/blob/master/src/GoTrueClient.ts#L99
```
    this.localStorage = settings.localStorage || globalThis.localStorage
```

In my environment attempting to access 
 property as indicated in the docs, doesn't help, because of this line:

https://github.com/supabase/gotrue-js/blob/master/src/GoTrueClient.ts#L99
```
    this.localStorage = settings.localStorage || globalThis.localStorage
```

In my environment attempting to access 
globalThis.localStorage
 generates an exception:
```
globalThis.localStorage
Uncaught 
Exception { name: "NS_ERROR_NOT_AVAILABLE", message: "", result: 2147746065, ...8<... }
```

It seems like subsequent uses of 
 generates an exception:
```
globalThis.localStorage
Uncaught 
Exception { name: "NS_ERROR_NOT_AVAILABLE", message: "", result: 2147746065, ...8<... }
```

It seems like subsequent uses of 
this.localStorage
 are protected from being 
 are protected from being 
null
 but setting it to null in the settings doesn't have any effect (and, predictably, it isn't possible to assign 
 but setting it to null in the settings doesn't have any effect (and, predictably, it isn't possible to assign 
null
 to 
 to 
globalThis.localStorage`), eg here:

export const getItemSynchronously = (storage: SupportedStorage, key: string): any | null => {
  const value = isBrowser() && storage?.getItem(key)
export const getItemSynchronously = (storage: SupportedStorage, key: string): any | null => {
  const value = isBrowser() && storage?.getItem(key)

https://github.com/supabase/gotrue-js/blob/master/src/lib/helpers.ts#L62

I know my environment is somewhat unusual, but it seems like this is actually a bug (since localStorage cannot be nullish).

What do you think?

[1] https://supabase.com/docs/reference/javascript/next/initializing#with-additional-parameters
screenshot.png
Initializing | Supabase
You can initialize a new Supabase client using the createClient() method.
GitHub
gotrue-js/helpers.ts at master · supabase/gotrue-js
An isomorphic Javascript library for GoTrue. Contribute to supabase/gotrue-js development by creating an account on GitHub.
gotrue-js/helpers.ts at master · supabase/gotrue-js
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

OAuth PKCE documentation needs an update for `createClient`
SupabaseSSupabase / help-and-questions
6mo ago
Documentation on stripe in edge function does not match implementation resulting in error.
SupabaseSSupabase / help-and-questions
4y ago
Error in createClient
SupabaseSSupabase / help-and-questions
4y ago
Multiple GoTrueClient error
SupabaseSSupabase / help-and-questions
3y ago