Cannot find name 'isBrowser' in nuxt.config.ts
im working on supabase auth in nuxt 4.1.3. here is my config, i have followed the docs using isBrowser() but it said "Cannot find name 'isBrowser'"
2 Replies
Hi @Asher. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error "Cannot find name 'isBrowser'" occurs because there is no built-in isBrowser() function in Nuxt. In Nuxt, to check if code is running on the client (browser), you should use the built-in variables or methods such as process.client (Nuxt 2) or import.meta.client (Nuxt 3/4), or use composables like useNuxtApp(). There is no mention of isBrowser() in the official Nuxt documentation or the knowledge sources provided.
For example, if you want to conditionally set options based on whether you are in the browser, you can do:
Or, if you need to do this in runtime code (not config), you can use:
If you are following a guide or documentation that mentions isBrowser(), it is likely not for Nuxt or is outdated. Use import.meta.client for client-side detection in Nuxt 3/4 as per the official documentation and best practices Docs: Universal Rendering.
If you need to check for the client in runtime code, you can also use the useNuxtApp composable and its properties, but for config files, use import.meta.client as shown above.
There is no isBrowser() function in Nuxt, which is why you are seeing the error.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@358819659581227011> Kapa.ai is still learning and improving, please let me know how I did by reacting below.