-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Feature: Router Plugins #397
Conversation
✅ Deploy Preview for kitbag-router ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@stackoverfloweth couple tests are failing around global hooks. I realized when writing tests for plugins that global hooks didn't work like I expected. I could update the tests to reflect the current functionality, but thought it was worth discussing first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been wanting this for so long and assumed it would be incredibly difficult. I'm blown away by how simple this appears to be, so kudos on that. SUPER excited about what this will unlock for us ❤️
Description
Plugins add the ability to predefine router functionality to be used when creating a router. Plugins can add routes, rejections, and global hooks to a router.
Creating a plugin
Any object that satisfies the
RouterPlugin
type can be used. But the newcreateRouterPlugin
utility can be used to easily create plugins in a type safe manor.Installing plugins
Multiple plugins can be installed when creating a router using the 3rd argument of
createRouter
Type Safety
Any routes or rejections added by plugins will be available when navigating. Use
router.push
,router.reject
, and components likeRouterLink
like normal.