Srujan Purohit
12/08/2025, 7:59 AM@descope/angular-sdk package (version 0.21.11) is not compatible with Angular Server-Side Rendering (SSR) due to the underlying @descope/web-component package attempting to register custom elements during module initialization.
Error Details
Error Message:
ReferenceError: customElements is not defined
at 67077 (/path/to/dist/xyz/server/vendor.js:7609:1)
Root Cause: The @descope/web-component package (version 3.49.0) executes the following code at module load time:
customElements.get('descope-wc')
? console.log('descope-wc is already defined')
: customElements.define('descope-wc', DescopeWc);
loading from https://github.com/descope/angular-sdk/blob/main/projects/angular-sdk/src/lib/components/descope/descope.component.ts >> https://github.com/descope/descope-js/blob/main/packages/sdks/web-component/src/lib/descope-wc/index.ts
This code runs during server-side bundle compilation/execution where the customElements API (a browser-only Web Components API) is not available.
Environment
• Framework: Angular 17.3.2 with SSR
• Descope SDK Version: @descope/angular-sdk@0.21.11
• Web Component Version: @descope/web-component@3.49.0 (transitive dependency)
• Node.js Version: v22.19.0
• Build Tool: Angular CLI with Webpack bundling
Recommended Solutions
Option 1: Lazy/Deferred Custom Element Registration (Recommended)
Modify @descope/web-component to defer custom element registration until it's actually needed, rather than at module load time:
// Instead of immediate registration:
// customElements.define("descope-wc", DescopeWc);
// Use lazy registration:
export function registerDescopeWc() {
if (
typeof customElements !== 'undefined' &&
!customElements.get('descope-wc')
) {
customElements.define('descope-wc', DescopeWc);
}
}
// Or check for browser environment:
if (typeof window !== 'undefined' && typeof customElements !== 'undefined') {
customElements.define('descope-wc', DescopeWc);
}
Option 2: Environment Detection
Add environment detection to prevent registration in Node.js/SSR contexts:
const isBrowser =
typeof window !== 'undefined' && typeof customElements !== 'undefined';
if (isBrowser && !customElements.get('descope-wc')) {
customElements.define('descope-wc', DescopeWc);
}
Option 3: Separate Browser/Server Builds
Provide separate entry points or builds for browser and server environments, similar to how many libraries handle SSR compatibility.
Option 4: Dynamic Import Support
Support dynamic imports for the web component, allowing Angular SSR users to load it only in the browser:
// In Angular component
if (isPlatformBrowser(this.platformId)) {
await import('@descope/web-component');
}
Impact
• Current Impact: Blocks SSR builds from completing successfully
• User Impact: Prevents deployment of Angular applications using Descope with SSR enabled
Requested Action
Please update @descope/angular-sdk to:
1. Check for browser environment before registering custom elements
2. Defer registration until the component is actually used
3. Provide SSR-safe initialization patterns
Alternatively, provide official SSR compatibility guidance and/or a server-safe build variant.
Related Issues
This issue affects any Angular application using:
• Angular Universal / SSR
• Server-side rendering
• Static site generation (SSG)
• Any build process that evaluates modules in a Node.js environment
Date: 08/12/2025 SDK Version: @descope/angular-sdk@0.21.11 Web Component Version: @descope/web-component@3.49.0Rahul Rijhwani
12/08/2025, 9:35 AMRahul Rijhwani
12/08/2025, 9:37 AMSrujan Purohit
12/08/2025, 10:50 AMNick Rodriguez
12/08/2025, 6:53 PMAsaf Shen
12/08/2025, 6:58 PMSrujan Purohit
12/09/2025, 2:05 AMDescopeAuthModule (imported as root config for interceptor, services etc) >> ./components/descope/descope.component >> @descope/web-component.
Let me know if we need to connect over call.Asaf Shen
12/09/2025, 12:13 PMDescopeAuthModuleSrujan Purohit
12/09/2025, 1:25 PMSrujan Purohit
12/10/2025, 5:43 AMAsaf Shen
12/10/2025, 6:52 AMSrujan Purohit
12/10/2025, 10:24 AMAsaf Shen
12/11/2025, 8:03 AM