Quantcast
Channel: Active questions tagged svelte - Stack Overflow

Delaying render of webcomponent content

I have a website that uses webcomponents to add some extra interactivity.In this case a carousel created in Svelte<svelte:options customElement={{ tag: "carousel", shadow: "open"}} />The nice...

View Article


Is this object created only once or every time I import it? [duplicate]

Since I'm having a bug that I can't figure out, a cold doubt has assailed me:.I have the below code in a Svelte 5 SvelteKit app.And I'm importing import { queryClient } from './src/query.ts from...

View Article


How do I combine i18n-ally with Kaisermann/svelte-i18n library

I'm doing some internationalization with a Svelte project, and I'm using i18n-ally to do the language editing. i18n-ally does a great job of turning a block of code from:<p>Copyright &copy;...

View Article

Astro with Node Standalone Adapater for API - CORS issues

I'm working on a small Astro test project that uses the Node standalone adapter for an API endpoint.Then I'm using a Svelte form to POST to that endpoint like in this tutorial.I'm running the Node...

View Article

Svelte-flow async integration with indexedDB

ContextI'm using Svelte-Flow with Sevelte 5 for some project. To scale I want to have the object defining my node pushed to indexedDB. To keep it in sync and don't dodata handling twice, I want to sync...

View Article


Svelte 5 - using $state for class field in TypeScript

I have a class:class TestClass { prop = $state('test');}It works in .svelte.js and .svelte files with <script lang="js">, but doesn't work in .svelte.ts and .svelte files with <script...

View Article

SvelteKit: Run function at route change (for access token, without doing it...

I just started with SvelteKit and I have a question regarding functions, that should run on every route change. I did not find much, helpful information about it.Just to run it at the layout files...

View Article

How to `console.log('yes')` when a variable changed?

let c = 0;$: console.log(c);If we want to print the value of c when it is changed, we can write like above.Because c is used in $ directive literally, so this statement can be reactive to c.But what if...

View Article


How can I manually compile a svelte component down to the final javascript...

Our company produces an automation framework that is written in svelte/sapper. One feature is that developers can create custom ui widgets, currently using plain js/html/css and our client side api....

View Article


Access URL query string in svelte

How should I access the the query string parameters from svelte? I'd like my script to behave differently when "?beta" has been appended to the URL.My intuitive approach would be to use the standard...

View Article

Svelte 5 $state values do not update after destructuring

This REPL example shows that my destructured values are not reactive. Function getIntersectionState() returns a $state object:const { i, detectors, refreshState } = getIntersectionState();When I modify...

View Article

How can I check when object 'window' becomes available?

I am new to SvelteKit, and I am not familiar with SSR. I have recently learned that window is only defined after the client-side has been loaded, which can be determined with the onMount hook.But...

View Article

Supabase StorageApiError: The resource was not found

I'm trying to download a PDF file from a bucket from a SvelteKit endpoint.The file is there (I logged filePath and bucketName to the console and checked them against my actual bucket), and I think the...

View Article


How to Build to a Web Component from a Svelte Library?

I'm writing a Svelte(Kit) library that currently works by importing the svelte component.I've been requested to make it also available as a web component, i.e. something like:<script...

View Article

How do I use environment variables in a SvelteKit app hosted on Cloudflare...

I am making a site for a very small organisation I am involved in, and have been asked to design it in a way where hosting costs virtually nothing. I have opted to use SvelteKit (hosted on Cloudflare...

View Article


How to monitor a variable and run a function every time the variable changes?

It will be like the on:change event.I am not using this event because in some svelte libraries this event is not emitted, and the implication is to use binding and $.However, it seems that Svelte...

View Article

RSS feed's content doesn't show in RSS readers

I have created a SvelteKit application which serves an RSS feed at https://learn.flucoma.org/explore/rss.xml. The feed is valid, according to the W3C validator....

View Article


Web worker fail after setting COOP and COEP headers

I am using WASM SQLite in my project and in order to use it these two headers must be set to the following values."Cross-Origin-Opener-Policy": "same-origin","Cross-Origin-Embedder-Policy":...

View Article

Uncaught (in promise) ReferenceError: Buffer is not defined in vite/sveltekit...

I need a way to alias Buffer for the browser.Not sure which module requires this but its probably crypto related.500Buffer is not...

View Article

How to use Tween in actions?

Svelte 5 deprecated tweened and replaced it with Tween.tweened was a store, so in an action I could subscribe to the value and react to it that way (e.g. turn an offset into a line of CSS like...

View Article

Why not call a fetch function eagerly when it is not even awaited

I get this message in my terminal when running my svelte frontend:Avoid calling fetch eagerly during server side rendering — put your fetch calls inside onMount or a load function insteadI understand...

View Article


What may prevent Svelecte from rendering suggestions?

I used Svelecte to create autocomplete component to search books like following:<script> import Svelecte, { addFormatter } from 'svelecte'; let clearable = true; let resetOnBlur = true; let...

View Article


Image may be NSFW.
Clik here to view.

Referencing elements inside a writable List

I have the following list of Player objects {id:number, name:string} which is a globally stored element made using writable:// $lib/global.tsimport { writable } from 'svelte/store';import type { Player...

View Article

How can i navigate to different path on click in svelte?

Currently in having on:click | preventDefault="{() => showDetail({id})}"and in showDetail function i want to naviagte to particular id which in i am passing on click of button.I tried regular...

View Article

TypeError: Class extends value undefined is not a constructor or null (svelte...

I just got started with svelte and was trying to make an app with redis as the db. I made a typescript file with all the db functions I would need and tried to import it into my svelte components, but...

View Article


VSCode can't find scss import in Svelte component if path contains $lib alias

Vite preprocess can handle $lib aliases inside component styles.I would like to use<style lang="scss"> @import '$lib/styles/mixins'; ...</styles>which works as expected.But VSCode with...

View Article

Why won't vite server start?

I get an error when I start the dev server error when starting dev server: TypeError: Cannot redefine property: crypto at Function.defineProperty (<anonymous>) at installPolyfills...

View Article

How can I render a component in its own component (recursively) in svelte?

I'm trying to make a recursive component that acts as a sort of tree view, where the component takes in an array.App.svelte<script> import Tree from "./Tree.svelte" let name =...

View Article

Svelvet edge source is undefined

<script> import { Svelvet, Node, Edge } from 'svelvet'; // Make these reactive by declaring them with let // let nodes = [ // { // id: 'start', // position: { x: 100, y: 100 }, // data: { label:...

View Article



SvelteKit: How to refer to the /routes folder from components and endpoints...

The next is my (simplified) project structure:appname||__src| |__lib| |__routes||__jsconfig.jsonIn the jsconfig.js file, I have paths key with an alias to a './src/lib' folder in form of...

View Article


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>