Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to use a global $derived in Svelte 5?

$
0
0

I'm trying to create a global state with Svelte 5 and runes:

// store.svelte.tsexport const person = ({    name: '',});export const mrName = $derived('Mr. '+ person.name); // <-- problem!

I can't make $derived to work:

Cannot export derived state from a module.6 |  export const mrName = $derived("Mr. " + person.name);                                                           ^7 |

What's the correct approach to a global $derived?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



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