Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heybran/breeze-router
A lightweight, zero-dependency client-side router for single page applications (SPAs).
https://github.com/heybran/breeze-router
javascript router spa
Last synced: 2 days ago
JSON representation
A lightweight, zero-dependency client-side router for single page applications (SPAs).
- Host: GitHub
- URL: https://github.com/heybran/breeze-router
- Owner: heybran
- License: mit
- Created: 2023-05-12T14:35:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-07T13:56:17.000Z (over 1 year ago)
- Last Synced: 2024-03-15T15:07:58.400Z (8 months ago)
- Topics: javascript, router, spa
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/breeze-router
- Size: 88.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Breeze Router
A lightweight, zero-dependency client-side router for single page applications (SPAs).**Note: This project is not production ready and is still in development.**
## InstallationTo use this router in your project, install the router using npm:
```bash
npm install breeze-router
```## Usage
To use the router in your application, you need to import `BreezeRouter` and define routes and handlers using the `Router` class:
```javascript
import BeezeRouter from 'breeze-router';// Create a new `BreezeRouter` instance.
const ROUTER = new BreezeRouter();// Define routes using the `add()` method.
ROUTER.add('/', async () => {
// Handle the root route
});ROUTER.add('/about', async () => {
// Handle the about route
});ROUTER.add('/users/:userId', async ({ route, params }) => {
// Handle the users route with a dynamic parameter :userId
const userId = params.userId;
});ROUTER.add("/users/:username/posts/:postId", async ({ route, params }) => {
// Handle the posts route with a dynamic parameter :username and :userId
const { username, postId } = params;
});// Call the `start` method to start the router.
ROUTER.start();
```## Util functions
### `toggleParam(this, 1)`
```html
```
If checked, then it will append search params to url like this: `localhost/users?freelance=1`, if you click checkbox again, it will remove that search param from url.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.