Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
preact-router
Advanced tools
Connect your Preact components up to that address bar.
preact-router
provides a <Router />
component that conditionally renders its children when the URL matches their path
. It also automatically wires up <a />
elements to the router.
💁 Note: This is not a preact-compatible version of React Router.
preact-router
is a simple URL wiring and does no orchestration for you.If you're looking for more complex solutions like nested routes and view composition, react-router works great with preact as long as you alias in preact-compat. React Router 4 even works directly with Preact, no compatibility layer needed!
import Router from 'preact-router';
import { h, render } from 'preact';
/** @jsx h */
const Main = () => (
<Router>
<Home path="/" />
<About path="/about" />
<Search path="/search/:query" />
</Router>
);
render(<Main />, document.body);
If there is an error rendering the destination route, a 404 will be displayed.
:information_desk_person: Pages are just regular components that get mounted when you navigate to a certain URL.
Any URL parameters get passed to the component as props
.
Defining what component(s) to load for a given URL is easy and declarative.
You can even mix-and-match URL parameters and normal props
.
<Router>
<A path="/" />
<B path="/b" id="42" />
<C path="/c/:id" />
<D default />
</Router>
Lazy loading (code splitting) with preact-router
can be implemented easily using the AsyncRoute module:
import AsyncRoute from 'preact-async-route';
<Router>
<Home path="/" />
<AsyncRoute
path="/friends"
component={ () => import('./friends') }
/>
<AsyncRoute
path="/friends/:id"
component={ () => import('./friend') }
loading={ () => <div>loading...</div> }
/>
</Router>
FAQs
Connect your components up to that address bar.
The npm package preact-router receives a total of 14,845 weekly downloads. As such, preact-router popularity was classified as popular.
We found that preact-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.