https://github.com/upsilun/jsrouting
📍 A simple JavaScript routing system for web applications that leverages Apache .htaccess rules for handling single-page application (SPA) routes.
https://github.com/upsilun/jsrouting
javascript javascript-router js js-router jsrouter jsrouting route router routing routing-web
Last synced: 3 months ago
JSON representation
📍 A simple JavaScript routing system for web applications that leverages Apache .htaccess rules for handling single-page application (SPA) routes.
- Host: GitHub
- URL: https://github.com/upsilun/jsrouting
- Owner: upsilun
- Created: 2021-06-23T16:51:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-25T16:25:02.000Z (about 2 years ago)
- Last Synced: 2025-06-16T21:45:32.489Z (6 months ago)
- Topics: javascript, javascript-router, js, js-router, jsrouter, jsrouting, route, router, routing, routing-web
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JsRouting 📍💻
## About
JsRouting is a simple JavaScript routing system with one slash route `/`.
### Compatibility
- `https://example.com/example` ✔
- `https://example.com/:username` ✔
- `https://example.com/home/example` ❌
- `https://example.com/home/example/example/...` ❌
### CDN :
`https://cdn.jsdelivr.net/gh/im95u/JsRouting/index.js`
## Documentation 📜
1️⃣ First setup your server
Apache .htaccess
```js
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
```
Nginx
```js
location / {
try_files $uri $uri/ /index.html;
}
```
2️⃣ Second Start Using JsRoute
`🔴 Please make sure you use this code after the page has loaded successfully 🔴`
✨ Simple Route
```js
var jsRoute = new JsRoute();
jsRoute.get("/example", function() {
alert("Wow! 😁");
});
```
🎉 Parameter Route
```js
var jsRoute = new JsRoute();
jsRoute.get("/:username", function(username) {
alert("Wow! 😁\nUsername : " + username);
});
```
📛 Some Errors
```js
jsRoute.get("/example/two") ❌
```
```js
jsRoute.get("/example/:parameter") ❌
```
#### 🤔 If you have a problem, contact me via:
Issues section: https://github.com/im95u/JsRouting/issues
Discord: `upsilun#6775`