An open API service indexing awesome lists of open source software.

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.

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`