Comments (13)
Ok here's the update:
- I created the Advanced Usage doc explaining how to do transitions, nested routers, route groups
- For lazy loading: I've done some research, and that's actually something I might need to implement into the router itself and it's not very high in the priority list for me at the moment.
@hlobil and @ansarizafar if you're interested in the lazy loading, can you please create a separate issue? (and remember that PRs are welcome 😉 ) Thanks
from svelte-spa-router.
Here is a component that does lazy loading.
https://github.com/kaisermann/svelte-loadable
from svelte-spa-router.
Can you please open a separate issue for this?
from svelte-spa-router.
Hi @ansarizafar
That's a lot of requests 😄
- Lazy loading: this is not in scope right now. I would also need to do some research to see if that can be implemented in the application outside of this component specifically. I am happy to consider a PR for this however.
- Route groups: if I understand the feature correctly, you can do that by creating a new Svelte component as route, and include all components you want within that. You could also have multiple, nested svelte-spa-router components
- Hooks: Can you give me an example? There could likely be a way to do that by just using Svelte.
- Progress bars: same as above, can you please give me an example?
- Nested routes: As per point 2, you can create a Svelte component nesting your components, or you can have nested
<Router>
's - Animations can be done within the Svelte components itself. For example, you can wrap your component in a
<div transition:fade="{{delay: 250, duration: 300}}">..</div>
It sounds like I might need to create a documentation article on "advanced topics" and explain better how (at least some of) the points above could be achieved with existing features of the router and/or Svelte.
from svelte-spa-router.
Thanks for your reply. Lazy loading is very important for bundle size. It would be great, If we can use await import('./home-view') to load route component. For hooks please have a look at Vue router navigation guards https://router.vuejs.org/guide/advanced/navigation-guards.html#global-after-hooks
from svelte-spa-router.
I'll need to do some research to see what lazy loading would require. It might be able to do that with the current module too, by managing the lazy loading logic inside the application. I can also explore how it would affect the router itself if I were to add it there; my main goal is to keep the router as simple as possible, and offload most other features to Svelte or the application itself (see how querystring support was implemented: the router returns the string but doesn't parse that, to avoid adding an extra dependency).
For both lazy loading and hooks, I'm happy to accept PRs 😉 And maybe open a separate issue for each of them please.
In the meanwhile, I'm leaving this issue open to remind myself to add some docs for certain topics like nested routing, animations, etc.
from svelte-spa-router.
This is very interesting. I'll try it and see if this can work with the router seamlessly.
Haven't been able to look at the docs I promised I'd make yet, but hopefully in the next few days.
from svelte-spa-router.
@ItalyPaleAle any news for Lazy loading? Amazing project this one!
from svelte-spa-router.
@frederikhors check here: https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Advanced%20Usage.md#async-route-loading
from svelte-spa-router.
@frederikhors check here: https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Advanced%20Usage.md#async-route-loading
Thanks I see. But it just doesn't work with sveltejs Rollup template and () => import("")
?
Do we really need https://github.com/hmmhmmhm/svelte-spa-chunk?
from svelte-spa-router.
Thanks I see. But it just doesn't work with sveltejs Rollup template and
() => import("")
?Do we really need https://github.com/hmmhmmhm/svelte-spa-chunk?
Well, it depends on what you want to do.
You could just use () => import("")
(as long as you put the route definition object into an async function, and await for the import to complete before initializing the app). That would give you code splitting; however, all the JS modules would be loaded before the app is initialized. So, it's not lazy loading. It can still help for example with caching...
from svelte-spa-router.
@ItalyPaleAle with respect to transition, doing this
<div transition:fade="{{delay: 250, duration: 300}}">..</div>
for all pages/route components becomes cumbersome and repetitive after a while. is it possible to use a wrapper around the routes like this
<PageTransition>
<Router {routes}/>
</PageTransition>
N.B this does not work currently with svelte-spa-router.
from svelte-spa-router.
from svelte-spa-router.
Related Issues (20)
- a11y warnings HOT 1
- Active links - allow duplicate classes
- In vite, i can't use the proxy /dev HOT 1
- Redirection from route pre-condition HOT 5
- Nested routes as maps HOT 1
- If I want to go to the login page in the sidebar + SPA form, is it possible with route guard? HOT 4
- Is this not possible in routeLoaded? HOT 5
- What is the black bar in this image? HOT 2
- Feature request: Svelte 4 support HOT 13
- FEATURE REQUEST: pass next() in precondition to decide whether the router should *change* the current route HOT 1
- Load user data HOT 4
- How to check hash-bashed history HOT 1
- Is there an alternative to the "Failed to fetch dynamically import problem" issue in Vite + Svelte spa environment? HOT 1
- WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte. [email protected] HOT 8
- Typescript problematic types after "wrapping" the route HOT 2
- navigating within same component does not work HOT 5
- Typescript support: Package path ./wrap is not exported from package svelte-spa-router HOT 2
- Will the library support Svelte 5? HOT 5
- Authentication and Authorization HOT 6
- Layouts not exists for svelte-spa-router? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-spa-router.