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

Provide data to main Layout from any route in SvelteKit

$
0
0

I have to following folder structure and I'm struggling to find the best way to provide my main layout with some props.

src/└── routes/└── (app)/├── route1/│└──+page.svelte├── route2/│└──+page.svelte└──+layout.svelte 

To have more context, the main layout has a Sidebar menu component that needs a list of elements to render based on the selected route.So I need to find a way to communicate and change the props of one component in the main layout from any route.

I tried using slots and send the complete Sidebar as a slot for the main layout using a route layout but it didn't work. As far as I later understood, each layout can only have one main slot.I also tried to investigate if I can use a Global State somehow for this implementation but it feels way too complicated for what I'm trying to do.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



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