mhagmajer:server-router
Server router with authentication for Meteor
Introductory blog post: https://blog.hagmajer.com/server-side-routing-with-authentication-in-meteor-6625ed832a94.
Documentation: https://mhagmajer.github.io/server-router/.
Compatibility
Please beware that:
- versions 1.2.x and above require Meteor 1.6.1+
- versions 1.1.x and below require Meteor 1.4.4.2-1.6
Installing
meteor add mhagmajer:server-router
You can find Flow type definitions in /definitions.
Example
Server-side
1import { ServerRouter } from 'meteor/mhagmajer:server-router'; 2 3WebApp.connectHandlers.use(ServerRouter.middleware({ 4 paths: [], 5 routes: { 6 hello(name) { 7 this.res.end(`You ${name}, your id is ${this.userId}`); 8 }, 9 }, 10}));
Client-side
1import { ServerRouterClient } from 'meteor/mhagmajer:server-router'; 2 3const serverRouterClient = new ServerRouterClient({ 4 routes: { 5 hello: 1, 6 }, 7}); 8 9<Button onClick={() => { 10 serverRouterClient.redirect.hello('John'); 11}} />
Publishing (contributors)
Run npm run clean before meteor publish.