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

sveltekit Hash-based routing

$
0
0

I'm pretty new to svelte and especially SvelteKit. Currently, I'm working on 2 projects.

The 1st one is a SPA in which I use svelte-spa-router to manage the different states and bring the ability to navigate back and forward like we would do in an old-school website.This works perfectly :)

The 2nd project is a SvelteKit app. I have 3 use cases:

  1. Search a product
  2. Create a product
  3. Display the top 10 products

In the first place, I thought that it would be interesting to be able to prefetch some kind of JSON data if needed for each use case, but on the other hand, I didn't want to create a route page for each sub use case because I didn't want the page to refresh each time the user makes a simple action. So, I'm using 3 routes to navigate between these 3 "use cases":

src/routes/search_product/+page.sveltesrc/routes/create_product_page/+page.sveltesrc/routes/show_top_10_products/+page.svelte

Now, I have a problem ... there's 3 steps to create a product page. These 3 steps are represented by the 3 different Svelte components below:

  1. EnterProductBasicInfo.svelte
  2. UploadPictures.svelte
  3. GivePrices.svelte

If the user is in the process of creating a product page and is at step 2), he is shown the UploadPictures.svelte component .... but if he press the back button, he will quit the create_product_page route instead of getting back to step 1) that is the EnterProductBasicInfo.svelte component.

So, I was thinking that I may use the svelte-spa-router that I've used for the SPA, but I'm asking experts here if there is another built-in solution in SvelteKit to be able to manage routes without refreshing the whole page each time a route changes. If you have some good link about SPA, SSR, preloading vs prefetching, I'll take it cause it's still a bit blurry to me.

Thank you so much for your help.


Viewing all articles
Browse latest Browse all 1755

Latest Images

Trending Articles



Latest Images

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