saadeghi / svelte-countup

21 stars 5 forks source link

Sveltekit support #3

Open rbozan opened 4 months ago

rbozan commented 4 months ago

Hi, it doesn't work when using Sveltekit because of serverside rendering:

Error: <Countup> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <Countup>.
saadeghi commented 4 months ago

…why rendering it on server? it's for browser

rbozan commented 4 months ago

I understand that it's for the client and rendering on the server would be pointless but because of server side rendering Sveltekit will try to render your component on the server. Usually the component will have a check in place if you are on the server, and if so it will not try to render it on the server to avoid this error.

So I mean there should be a check in place to disable rendering on the server so we can use the component in Sveltekit.

saadeghi commented 4 months ago

Can you share a minimal reproduction link please? Because I'm also using it on sveltekit and there's no issue.