How to import private env variables when code is running on server and public env if running on a client
The problem: I have a very similar problem as this question, except I want to use the sveltekit dynamic variables instead of vite. I have an api client ApiClient.ts. I would like to use this ApiClient both on the client-side and on server-side for server side rendering. I have both sveltekit and api running in […]
SvelteKit is not storing cookies when doing a request inside of the `load` function
In my SvelteKit site I do a request to my backend inside of the LayoutServerLoad
function, in +layout.server.ts
. Namely when the site is opened with an ?affiliate_id=bla
query parameter, I want to send this to the backend:
Best Practices for Handling Login and Signup Forms in SvelteKit with External API Integration
I’m developing a SvelteKit application and need to implement login and signup forms that communicate with an external API. I’m looking for best practices on how to structure this functionality, particularly regarding the use of +page.svelte
and +page.server.ts
files.
Script added to `svelte:head` ends up being included twice
In my root +layout.svelte
file I have the following code:
sveltekit api requests parallel processing
//routes/quotes/+page.js export const load = async ({fetch}) => { // First Fetch Request to Quotes let quotes = []; const fetchQuotes = async () => { const resultQuotes = await fetch(‘https://dummyjson.com/quotes?limit=10’); const quotesData = await resultQuotes.json(); const quotes = quotesData.quotes console.log(“Q” + quotes); return quotes; } // Second Fetch Request to Comments let users = […]
SvelteKit: how to refresh state when opening the same route
I have a top menu bar with links to the different pages on my website. When somebody is on one of those pages and makes some state changes (like filling in a form), then I kind of expect the page to reset to its initial state when the user clicks on the same menu link again. But instead nothing really happens, the state doesn’t reset.
SvelteKit dynamic routing always 404 Not Found
I have a SvetleKit project where I want to add dynamic routes. It is my first big project where I use SvelteKit (it’s way better than React ;). Suppose I have a page on which a lot of objects are displayed in an overview and I want to add a detailed view of each individual object. For the summary I created a /src/routes/overview folder with a +page.svelte for the summary of all objects. For the detailed view, I have made a folder with square brackets around an ID and a +page.svelte, i.e. /src/routes/overview/[objectId]/+page.svelte. But no matter what I do, whenever I navigate to a dynamic route, the content of the +page.svelte in the [objectId] folder is not displayed on the page, but 404 NotFound. I didn’t put anything dynamic in the +page.svelte for testing purposes, only static “HTML”.
Doing API calls in a hook after HTTP request has finished in SvelteKit
I have some statistics and notification API requests I’d like to do in my +server.js code.
How to deploy a static sveltekit app on nginx?
trying to figure out how to host the sveltekit frontend app built with static-adapter.
Here’s my svelte config:
how to node path module in sveltekit
in express app, I used to do this