Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.

a7 Router

anton7r edited this page Dec 15, 2019 · 2 revisions

a7.routes

It's the router of a7JS and it is in it self pretty self explanatory. Essentially it takes a route / path / URL inside your app. And when it routes to a given url it will show the page that you attached to it. in order to get this setup completely you have to setup your server in a way that it would give the user the index.html when a resource is not found

The * (Star) Symbol

It is used to match URL where the starting bit until to the * is the same and anything after it. For example /users/* would be matched with /users/bob and /users/bob/likes

Syntax

a7.routes({
    "/route": component()
})

Examples

/* index.js */
import a7 from "a7js";
import homePage from "./components/homePage/homePage.js";

a7.routes({
    //when user goes to homepage 
    "/home": homePage()
})

if you want it to go to homepage when no other route is found do the following

a7.routes({
    //this matches every page which are not otherwise declared here in the routes
    "/*": homePage()
})

if you would have different users in your app and you would show their profile with a following url example.com/users/username this is the way you could do it

a7.routes({
    "/users/*": userPage()
})
Clone this wiki locally