diff --git a/src/index.ts b/src/index.ts index ff601926..b0ef3ae4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,3 +39,31 @@ export const createClient = < ): SupabaseClient => { return new SupabaseClient(supabaseUrl, supabaseKey, options) } + +// Check for Node.js <= 18 deprecation +function shouldShowDeprecationWarning(): boolean { + if ( + typeof window !== 'undefined' || + typeof process === 'undefined' || + process.version === undefined || + process.version === null + ) { + return false + } + + const versionMatch = process.version.match(/^v(\d+)\./) + if (!versionMatch) { + return false + } + + const majorVersion = parseInt(versionMatch[1], 10) + return majorVersion <= 18 +} + +if (shouldShowDeprecationWarning()) { + console.warn( + `⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` + + `Please upgrade to Node.js 20 or later. ` + + `For more information, visit: https://github.com/orgs/supabase/discussions/37217` + ) +}