How do I know if the Angular is running in SSR?

Discussão em 'Angular' iniciado por Terry Windwalker, Abril 6, 2025.

  1. When I was running the Angular application, I tried to use the following code to determine whether the Angular app is running in SSR or CSR.

    const platformId = inject(PLATFORM_ID);
    console.log('Identify CSR: ', isPlatformBrowser(platformId));
    console.log('Identify SSR: ', isPlatformServer(platformId));


    When I run it, the "Identify SSR" is true in the console in my VS Code, and the "Identify CSR" is true in the console in my browser.

    How can I tell if it is actually running in SSR or not?

    Continue reading...

Compartilhe esta Página