Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libs/data-access-supabase/src/lib/supabase-client.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isPlatformBrowser } from '@angular/common';
import { Optional, PLATFORM_ID, type Provider } from '@angular/core';
import { createClient, type SupabaseClient } from '@supabase/supabase-js';

Expand All @@ -8,6 +7,15 @@ import {
type SupabaseConfig,
} from './supabase-config';

/**
* Same check as Angular `isPlatformBrowser(PLATFORM_ID)` (`'browser'`),
* without importing `@angular/common` (that pulls PlatformLocation and breaks
* non-Angular bundles such as `apps/web-react`).
*/
function isBrowserPlatform(platformId: object | string): boolean {
return platformId === 'browser';
}

/** Plain Supabase client holder — wire via provideSupabaseClient() (no @Injectable). */
export class SupabaseClientService {
private client: SupabaseClient | null | undefined;
Expand All @@ -23,7 +31,7 @@ export class SupabaseClientService {

/** Browser-only client when URL + anon/publishable key are configured. */
getClient(): SupabaseClient | null {
if (!isPlatformBrowser(this.platformId)) {
if (!isBrowserPlatform(this.platformId)) {
return null;
}
if (this.client !== undefined) {
Expand Down
Loading