Closed threeaccents closed 4 months ago
This error is common when using SSR. You have a couple options:
Disabling SSR SSR is enabled by default when you install LiveSvelte. If you don't want to use Server-Side Rendering for Svelte, you have 2 options:
Globally If you don't want to use SSR on any component you can disable it globally. This will automatically be the case if you don't include the NodeJS supervisor in the application.ex file
Component To disable SSR on a specific component, set the ssr property to false. Like so:
<.svelte name="Example" ssr={false} />
onMount
.onMount(async () => {
const leaflet = await import('leaflet');
// Your leaflet code here...
});
Here's a link to a more detailed example using SvelteKit. Note: I've only tried this approach in a SvelteKit app, but pretty sure it should work with LiveSvelte as well. Hope this helps!
Thank you that is exactly what I was looking for!
@tonydangblog Thank you :fire:
Versions:
I'm trying to integrate leaflet into a LiveSvelte program. I've tried both using the
V
sigil and the custom svelte component approach; however, I always end up running into this error when importing leafletThis happens as soon as I try to import
leaflet
.Do I need the
server.js
file if I won't be doing ssr? I removed it from being built in thebuilt.js
file. Not sure if this is the right approach. I'm probably missing something obvious. I'm not too familiar with the FE ecosystem anymore.