Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SvelteKit: Cannot reference store value inside <script context="module" />

SvelteKit / Svelte : Not able to get or set (Read or Write) values from the "store" in the context module.

import {selectedStore} from "src/storelocation";

<script context="module">
  export const load = async ({params})=> {
    
     $selectedStore.value // throwing error
  }
like image 686
RajuPedda Avatar asked Sep 14 '25 13:09

RajuPedda


1 Answers

import {selectedStore} from "src/storelocation";
import { get } from 'svelte/store';

<script context="module">
export const load = async ({params})=> {

  // use this
 get(selectedStore).value;
}
like image 86
RajuPedda Avatar answered Sep 17 '25 18:09

RajuPedda