Skip to content

Conversation

@lgriffin
Copy link
Contributor

@lgriffin lgriffin commented Jul 7, 2025

Problem
The application build was failing during server-side rendering (SSR) with the error: Apply to icon-lib.ts
This occurred because the theme store subscription was directly accessing document.body.className during server-side rendering, where the document object is not available.

Solution
Added browser detection import from $app/environment Wrapped document.body.className assignment in a browser check to prevent server-side execution Fixed TypeScript typing issues for dynamic icon library access Changes

Fixed: SSR build failure by adding browser detection guard Improved: Type safety for icon library dynamic access
Maintained: All existing functionality for client-side theme switching

Please check if the PR fulfills these requirements

  • The commit message is sensible and easily understood
  • Tests for the changes have been added (for bug fixes / features where relevant)
  • Docs have been added / updated (for bug fixes / features where relevant)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What commits does this PR relate to?

Thank you for your contribution

We hope you stay around and connect with our growing community!

Problem
The application build was failing during server-side rendering (SSR) with the error:
Apply to icon-lib.ts
This occurred because the theme store subscription was directly accessing document.body.className during server-side rendering, where the document object is not available.
Solution
Added browser detection import from $app/environment
Wrapped document.body.className assignment in a browser check to prevent server-side execution
Fixed TypeScript typing issues for dynamic icon library access
Changes
Fixed: SSR build failure by adding browser detection guard
Improved: Type safety for icon library dynamic access
Maintained: All existing functionality for client-side theme switching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant