
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Basic browser router based on history package
I built this with a goal of having very simple browser router for my React.js projects. The code is very down-to-earth, yet capable to do it's job - routing, redirecting, working with protected routes.
Install the package with npm:
$ npm install --save router420
Then integrate it into your project with bundle like webpack, and start writing the code:
import { Router, Route, browserHistory} from 'router420';
//...your other imports
<Router styles={styles.container} history={browserHistory}>
<Route exactly pattern='/' component={AuthFormContainer} />
<Route exactly pattern ='/customer' component={CustomerRoute} />
<Route exactly pattern='/customer/orderCreation' component={OrderCreationRoute} />
<Route exactly pattern='/customer/orderCreation/orderCreationForm' component={OrderCreationFormRoute} />
</Router>
You can easily write your own protected routes using Redirect. Just remember that protected route's component needs to access the credentials. In this example I pass them from Redux store, yet Redux isn't a requirement for this router.
import { Redirect } from 'router420';
// ...other imports
class CustomerRoute extends React.Component {
checkCredentials = () => {
if (this.props.isLogged && this.props.role === 'customer'){
return(
<CustomerMain />
)
} else {
return <Redirect to={'/'} />
}
}
render(){
return(
this.checkCredentials()
)
}
}
For programmatical navigation there some helper functions for history api:
import { locationPush, locationReplace } from 'router420';
//...
locationPush('/some/cool/route')
Beware that for now React forbids to return array of elements without wrapping tags, so this router will produce one container div which you can style through passing prop "styles". This isn't cool and I will fix that issue.
FAQs
Simple browser router based on history package
The npm package router420 receives a total of 0 weekly downloads. As such, router420 popularity was classified as not popular.
We found that router420 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.