Is it possible to access Svelte store from external js files?

Yes, absolutely.

For one thing, the store API is very simple and nothing prevents you from subscribing to the store yourself to know the value:

import myStore from './stores'

myStore.subscribe(value => {
  // do something with the new value
  // you could store it for future reference...
})

And, if you just want to know the current value, Svelte has a helper for that, the get function:

import { get } from 'svelte/store';

import myStore from './stores'

const value = get(myStore);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)