diff --git a/README.md b/README.md index d1cd50e..46d77b6 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ A tiny URL router for [Nano Stores](https://github.com/nanostores/nanostores) state manager. -* **Small.** 684 bytes (minified and brotlied). Zero dependencies. -* Good **TypeScript** support. -* Framework agnostic. Can be used with **React**, **Preact**, **Vue**, +- **Small.** 684 bytes (minified and brotlied). Zero dependencies. +- Good **TypeScript** support. +- Framework agnostic. Can be used with **React**, **Preact**, **Vue**, **Svelte**, **Angular**, **Solid.js**, and vanilla JS. Since Nano Stores promote moving logic to store, the router is a store, @@ -51,24 +51,21 @@ export const Layout = () => { --- - Made in Evil Martians, product consulting for developer tools. + Made in Evil Martians, product consulting for developer tools. --- - ## Install ```sh npm install nanostores @nanostores/router ``` - ## Usage See [Nano Stores docs](https://github.com/nanostores/nanostores#guide) about using the store and subscribing to store’s changes in UI frameworks. - ### Routes Routes is an object of route’s name to route pattern: @@ -111,10 +108,9 @@ createRouter({ */ ``` - ### Search Query Routing -Router value contains parsed url search params: +Router value contains parsed URL search params (like `?sort=name`): ```js createRouter({ home: '/posts/:category' }) @@ -143,7 +139,6 @@ router.get() //=> { // } ``` - ### Clicks Tracking By default, router and `?search` params store will add `click` event listener @@ -173,7 +168,6 @@ export const Link = (props) => { } ``` - ### URL Generation Using `getPagePath()` avoids hard coding URL in templates. It is better @@ -192,7 +186,7 @@ or `redirectPage`: ```ts import { openPage, redirectPage } from '@nanostores/router' -function requireLogin () { +function requireLogin() { openPage($router, 'login') } @@ -209,7 +203,6 @@ getPagePath($router, 'list', { category: 'guides' }, { sort: 'name' }) //=> '/posts/guides?sort=name' ``` - ### Server-Side Rendering Router can be used in Node environment without `window` and `location`.