-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with Svelte 4 #1621
Comments
Hey! I am not able to reproduce this issue. We actually have a Svelte playground included in the project, which is on Svelte 4.x, and I just tested it and it works fine: https://github.com/inertiajs/inertia/tree/master/playgrounds/svelte I am going to close this issue for now, but feel free to provide us with a minimal reproduction of the issue you're experiencing as a Git repo and we can have another look 👍 |
@reinink here is an example repository: https://github.com/punyflash/inertia-test. A bit detailed explanationI created 2 pages: Page 1<script lang="ts" context="module">
// import LayoutInsideTag from "@/components/LayoutInsideTag.svelte";
import LayoutOutsideTag from "@/components/LayoutOutsideTag.svelte";
export const layout = [LayoutOutsideTag];
</script>
<script lang="ts">
import { fade } from 'svelte/transition';
import { inertia } from "@inertiajs/svelte";
export let title = '';
export let data = '';
</script>
<svelte:head>
<title>{title}</title>
</svelte:head>
<section in:fade>
<h1 class="text-3xl">{title}</h1>
<div>{data}</div>
<a href="/page/2" class="underline" use:inertia>Go to page 2</a>
</section> Page 2<script lang="ts" context="module">
// import LayoutOutsideTag from "@/components/LayoutOutsideTag.svelte";
import LayoutInsideTag from "@/components/LayoutInsideTag.svelte";
export const layout = [LayoutInsideTag];
</script>
<script lang="ts">
import { fade } from 'svelte/transition';
import { inertia } from "@inertiajs/svelte";
export let title = '';
export let data = '';
</script>
<svelte:head>
<title>{title}</title>
</svelte:head>
<section in:fade>
<h1 class="text-3xl">{title}</h1>
<div>{data}</div>
<a href="/page/1" class="underline" use:inertia>Go to page 1</a>
</section> Expected behavior (Svelte 3)Actual (Svelte 4) |
@punyflash Thanks for sharing! |
Hey! any updates on this? |
Hey @punyflash, thanks for reporting this bug. At my company we were upgrading to Svelte 4 and ran into the same issue with persistent layouts. My coworker found your issue and confirmed it using the Svelte playground. I was able to identify that this issue started happening in Svelte v4.1.1. The solution for now is to force Svelte v4.1.0. I won't have time to work on a fix in the next two weeks. When I get a chance I will try to determine if this is a bug on our side or Svelte's. On our side it could be related to the key part of this each block 🤷♂️ cc/ @bbauti |
Hi there, A nice fellow on Discord sent me here, kudos to him/her! I can confirm the bug with both versions 4.1.1 and 4.1.0 of Svelte, although the behavior is different. On version 4.1.1 the main On version 4.1.0 it works better, but still fails if I do the login from a page other than Downgrading to Svelte 4.0.0 works properly for me! I'll stick to version 4.0.0 until things are fixed on either side. Good luck with this bug, and thanks for this great tool! Best, |
svelte v5 won't work too |
Damn, i thought it was from my end, battled this for hours 🥲 |
As it seems the package is dead and most of crucial PRs are hanging for almost a year (#1614, #1763, #1635), I created my own adapter for Svelte with typescript support and some issues fixed regarding styles and props loading. You are free to use it: https://github.com/westacks/inertia-svelte. You can natively replace the inertia adapter, and it will work as it is. |
Cool, what makes the maintainer of this library not update it anymore? At least can the public make pr? |
@punyflash How do I install it? |
npm i @westacks/inertia-svelte |
Update package to 1.0.20, it should work now even if you don't use typescript |
Thank you, it works now. 👍 If you don't mind, can you take a look at issue #1785 |
@Dibbyo456 I put in a PR over at the westacks repo that solves the unknown prop issue. Still trying to sort through the unexpected slot part but I'm not too sure where that's coming from, will keep this updated if I can figure it out. |
@joshstobbs thanks for the PR. FYI, when using Svelte 5 the warning do not appear. |
Oh that’s really cool @Dibbyo456! I haven’t actually been able to get Inertia to work with Svelte 5, any chance you have an example repo? |
Just follow this guide, unfortunately SSR is broken #1801 😕 |
Seems a PR was sent in for this: #1763. Let's see how it goes. Thanks all. |
Hey folks! Just merged in #1763 — let's hope this is all resolved now. Will try and get a release out shortly 👍 |
This fix has been released as part of v1.0.16 👍 |
This guide from @danmatthews seems to have moved to this url: https://danmatthews.me/posts/you-can-use-svelte-v5-with-inertiajs-really-easily-today-bf9de |
Version:
@inertiajs/svelte
version: 1.0.9svelte
version: 4Describe the problem:
When using Svelte 4, props are not being populated on inertia router visits. Also when adding svelte-eslint to the project pages are completely empty after visit.
Steps to reproduce:
Just make a visit using inertia link or router to the route that requires any props
The text was updated successfully, but these errors were encountered: