
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
universal-router
Advanced tools
A simple middleware-style router that can be used in both client-side (e.g. React, Vue.js) and server-side applications (e.g. Node.js/Express, Koa).
Visit Quickstart Guide (slides) | Join #universal-router on Gitter to stay up to date
✓ It has simple code
with only single path-to-regexp dependency
✓ It can be used with any JavaScript framework such as React, Vue.js etc
✓ It uses the same middleware approach used in Express and Koa, making it easy to learn
✓ It supports both imperative and
declarative routing style
✓ Routes are plain JavaScript objects with which you can interact as you like
Using npm:
$ npm install universal-router --save
Or using a CDN like unpkg.com with the following script tag:
<script src="https://unpkg.com/universal-router@4.2.0/universal-router.min.js"></script>
import UniversalRouter from 'universal-router';
const routes = [
{
path: '', // optional
action: () => `<h1>Home</h1>`,
},
{
path: '/posts',
action: () => console.log('checking child routes for /posts'),
children: [
{
path: '', // optional, matches both "/posts" and "/posts/"
action: () => `<h1>Posts</h1>`,
},
{
path: '/:id',
action: (context) => `<h1>Post #${context.params.id}</h1>`,
},
],
},
];
const router = new UniversalRouter(routes);
router.resolve('/posts').then(html => {
document.body.innerHTML = html; // renders: <h1>Posts</h1>
});
Play with an example on JSFiddle, CodePen, JS Bin in your browser or try RunKit node.js playground.
Universal Router supports all popular browsers, including Internet Explorer 9 and above
with polyfills such as es6-shim for
Map
,
Promise
and
Object.assign
that must be included before any other code.
For compatibility with older browsers you may also need to include polyfills for
Array.isArray
and Object.create
.
:mortar_board: ES6 Training Course
by Wes Bos
:green_book: You Don't Know JS: ES6 & Beyond
by Kyle Simpson (Dec, 2015)
:page_facing_up: You might not need React Router
by Konstantin Tarkus
:page_facing_up: An Introduction to the Redux-First Routing Model
by Michael Sargent
Does your company use Universal Router in production? Please consider sponsoring this project. Your help will allow maintainers to dedicate more time and resources to its development and support.
♥ Universal Router? Become a backer to show your support and help us maintain and improve this open source project. Get your image on our README with a link to your site.
Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issues or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.
Copyright © 2015-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.
Made with ♥ by Konstantin Tarkus (@koistya, blog), Vladimir Kutepov (frenzzy) and contributors
[4.2.0] - 2017-09-20
const routes = [
{ path: '/posts', ... }, // matches both "/posts" and "/posts/"
{ path: '/posts/', ... }, // matches only "/posts/"
]
const router = new UniversalRouter({
name: 'page',
path: ['/one', '/two', /RegExp/], // only first path is used for url generation
})
const url = generateUrls(router)
url('page') // => /one
FAQs
Isomorphic router for JavaScript web applications
The npm package universal-router receives a total of 11,468 weekly downloads. As such, universal-router popularity was classified as popular.
We found that universal-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.