
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@storeon/router
Advanced tools
Storeon Router which solves the problem of routing your application, providing full control over the route.
It size is 650 bytes (minified and gzipped) and uses Size Limit to control size.
npm install @storeon/router
# or
yarn add @storeon/router
If you want to use the router you should import the router.createRouter
from @storeon/router
and add this module to createStore
.
import createStore from 'storeon'
import useStoreon from 'storeon/react'
import router from '@storeon/router'
const store = createStore([
router.createRouter([
['/', () => ({ page: 'home' })],
['/blog', () => ({ page: 'blog' })],
['/blog/post/*', (id) => ({ page: 'post', id })],
[
/^blog\/post\/(\d+)\/(\d+)$/,
(year, month) => ({ page: 'post', year, month })
]
])
])
function Root() {
const { [router.key]: route } = useStoreon(router.key)
switch (route.match.page) {
case "home":
return <Home/>
case "blog":
return <Blog/>
case "post":
return <Post year={route.match.year} month={route.match.month} id={route.match.id}/>
default:
return <NotFound/>
}
}
store.dispatch(router.navigate, '/')
If you want to use the router with Svelte you should import the router.createRouter
from @storeon/router and add this module to createSvelteStore
instead of createStore
store.js
import { createSvelteStore } from "@storeon/svelte";
import { createRouter } from '@storeon/router'
const connect = createSvelteStore([
createRouter([
['/', () => ({ page: 'home' })],
['/blog', () => ({ page: 'blog' })],
])
])
And use it like:
App.svelte
<script>
import { connect } from "./store.js";
import router from "@storeon/router"
const moduleRouter = connect(router.key)
</script>
You can access the router like default svelte store via $:
{$moduleRouter.match.page}
import router from '@storeon/router'
const moduleRouter = router.createRouter([
[path, callback]
])
Function router.createRouter
could have options:
router.key
– key for store.
router.navigate
– navigation action.
router.changed
– change event of pathname.
Add data-ignore-router
attribute to the link so that the router ignores it.
MIT
FAQs
Storeon module for URL routing
The npm package @storeon/router receives a total of 120 weekly downloads. As such, @storeon/router popularity was classified as not popular.
We found that @storeon/router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.