Questions tagged [sveltekit]

[SvelteKit](https://kit.svelte.dev/) is a framework for building fullstack web applications with the Svelte framework.

SvelteKit is a framework for building fullstack web applications with the Svelte framework.

2260 questions
8
votes
2 answers

How to not reset the form on submit with `use:enhance` in Svelte?

I have a form that updates a product's information using a form with use:enhance and actions defined in +page.server.ts - However, whenever I submit the form, use:enhance resets the form elements and they all become blank, which is unexpected as the…
Basil
  • 488
  • 1
  • 15
8
votes
1 answer

SvelteKit fails to Run Dev | [plugin externalize-deps] Missing "./vite" export in "@sveltejs/kit" package

Following the Sveltekit docs here: https://kit.svelte.dev/docs/creating-a-project Everything is fine up until the npm run dev command, then this results: $ npm run dev > hoa@0.0.1 dev > vite dev X [ERROR] [plugin externalize-deps] Missing "./vite"…
theUnseen
  • 81
  • 2
8
votes
2 answers

SvelteKit - api response data (PageData) not updated after initial render

am new to svelte and svelteKit in general and am trying to load data from api and I followed the sveltekit todo sample code. It's working well for initial rendering and a tag onClick but in div on:click am updating url parameters api getting called…
MathankumarK
  • 2,717
  • 1
  • 17
  • 34
8
votes
3 answers

Cannot find module [...] or its corresponding type declarations (js2307) when importing from "$lib" with SvelteKit

Using the latest SvelteKit (1.0.0-next.401) I have a problem importing components from lib using the $lib syntax. I get an error and a red squiggly line (even though the import and web app works fine). The error message is as follows: Cannot find…
Anton Ödman
  • 451
  • 3
  • 7
  • 17
8
votes
4 answers

How to Fetch Data inside SvelteKit Component that Is Not a Page

SvelteKit v1.0.0-next.324 I have a SvelteKit component that is used in multiple places in my app, and it needs to fetch its own data from one of my endpoints. I read this question that states I can't have a load function unless it's a page. Assuming…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
8
votes
1 answer

How do I disable minification when running "build" command in sveltekit?

I am deploying sveltekit to a dfinity container and I need to disable minification to debug. I have to build a static version to deploy it with npm run build -- is there a vite option to disable minification? I've tried this: svelte.config.js but it…
chovy
  • 72,281
  • 52
  • 227
  • 295
8
votes
6 answers

Sveltekit: Styling active links with $page.path

I'm working on a sveltekit app with a sidenav containing links. I can't get the active class styling on my links to work properly. The links are components in NavLink.svelte: