'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
  }


Solution 1:[1]

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

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

  // use this
 get(selectedStore).value;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alberto León