Skip to content

πŸ“ A simple JavaScript routing system for web applications that leverages Apache .htaccess rules for handling single-page application (SPA) routes.

Notifications You must be signed in to change notification settings

upsilun/JsRouting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 

Repository files navigation

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

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

Nginx

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

var jsRoute = new JsRoute();

jsRoute.get("/example", function() {
  alert("Wow! 😁");
});

πŸŽ‰ Parameter Route

var jsRoute = new JsRoute();

jsRoute.get("/:username", function(username) {
  alert("Wow! 😁\nUsername : " + username);
});

πŸ“› Some Errors

jsRoute.get("/example/two") ❌
jsRoute.get("/example/:parameter") ❌

πŸ€” If you have a problem, contact me via:

Issues section: https://github.com/im95u/JsRouting/issues

Discord: upsilun#6775

About

πŸ“ A simple JavaScript routing system for web applications that leverages Apache .htaccess rules for handling single-page application (SPA) routes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published