-
Hi @henrygd , I like your project a lot and would like to use it in a svelte-kit project. My approach was something like that:
It results in
I already added
to my vite.config.js but that did not help. Any tip on how to proceed here would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi, It does return a Svelte component when initialized, but the usage remains the same as the vanilla version. It also needs access to the target element, so should only be initialized in the browser. Something like below should work in SvelteKit, or just initialize in I'll update the docs with examples of different ways to use in SvelteKit in the near future since you're not the only one who has had questions about this. import { browser } from "$app/env";
import BiggerPicture from "bigger-picture";
import type { BiggerPictureInstance } from "bigger-picture";
let bp: BiggerPictureInstance
if (browser) {
bp = BiggerPicture({ target: document.body });
} Edit: Just want to specify that the above is for apps using SSR like SvelteKit. If you only use Svelte on the client side then you don't need to worry about which environment you're in -- you should always have access to the DOM. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks a ot for your quick reply. I still have some issues (which may also be a result of not using TypeScript in my current project). |
Beta Was this translation helpful? Give feedback.
-
Just made a repo that I'll post examples in: https://github.com/henrygd/bigger-picture-examples So far I have a basic SvelteKit example in typescript and vanilla. No readme yet, but it should be straightforward enough. This is what the example site looks like: https://bp-sveltekit.vercel.app Also, it seems there's a bug in Svelte 3.50.0 that breaks the transitions in the library, so please use 3.49.0 or import |
Beta Was this translation helpful? Give feedback.
-
Wow, thanks so much @henrygd, with the tutorial integration worked like a charm! :) |
Beta Was this translation helpful? Give feedback.
Just made a repo that I'll post examples in: https://github.com/henrygd/bigger-picture-examples
So far I have a basic SvelteKit example in typescript and vanilla. No readme yet, but it should be straightforward enough. This is what the example site looks like: https://bp-sveltekit.vercel.app
Also, it seems there's a bug in Svelte 3.50.0 that breaks the transitions in the library, so please use 3.49.0 or import
bigger-picture/vanilla
until it's fixed.