Metor JS does not come with support for routing (i.e. having separate pages) out-of-the-box. But it is easy to add that using the router
smart package.
Install the router
smart package
Assuming that you have Meteorite
installed. Just run:
mrt add router
Configure routes in your client JavaScript
Update your client JavaScript code to also contain the following:
/**
* Routing
*/
Meteor.Router.add({
'/example': 'my-example',
'/': 'welcome',
'*': '404'
});
Update your HTML template
Now, we do not want to render all templates every time the page is loaded. It’s easy to fix my updating your templates slightly with the renderPage
function.
Example service
name="menu">
name="welcome">
This is the start page
name="my-example">
My example
This is an example page
name="404">
Oops, page not found
The page you were looking for has gone missing!
More features available
This is just a basic example of how to use the router
smart package. Check out the project’s webpage for detailed documentation.