kriasoft / universal-router

A simple middleware-style router for isomorphic JavaScript web apps
https://www.kriasoft.com/universal-router/
MIT License
1.7k stars 104 forks source link

How can I get current route name? #144

Closed luongthanhlam closed 6 years ago

frenzzy commented 6 years ago

Current route object is available via context.route:

const route = {
  name: 'Post',
  path: '/post/:id',
  action(context) {
    console.log('Current route name is:', context.route.name);
  },
};

Demo: https://jsfiddle.net/frenzzy/h2t9ou5n/

luongthanhlam commented 6 years ago

Thanks a lot