# @zxlib/solid-router5

> Router for solid-js based on router5 lib

Latest version **0.0.1** (published 2020-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zxlib/solid-router5
pnpm add @zxlib/solid-router5
yarn add @zxlib/solid-router5
bun add @zxlib/solid-router5
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-07-03 |
| First published | 2020-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Aleksander V. Dyomin |
| Maintainers | cyberlaborant |
| Keywords | typescript, solid-js, router, router5, solid-router, solid-router5 |

## Links

- npm: https://www.npmjs.com/package/@zxlib/solid-router5
- Repository: https://github.com/zxlib/solid-router5
- Homepage: https://github.com/zxlib/solid-router5#readme
- Issues: https://github.com/zxlib/solid-router5/issues
- npm.io page: https://npm.io/package/@zxlib/solid-router5

## Dependencies (1)

- [router5](https://npm.io/package/router5.md) ^8.0.0

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2020-07-03

## README

# Router for solid js

## Installation

```bash
npm install @zxlib/solid-router5
```

## Usage

```tsx
import { Link, RouterProvider, ShowRoute } from '@zxlib/solid-router5';
import createRouter, { Route } from 'router5';
import browserPlugin from 'router5-plugin-browser';
import { Component } from 'solid-js';

export const routes: Route[] = [
  { name: 'index', path: '/' },
  { name: 'route1', path: '/route1' },
  { name: 'route2', path: '/route2' },
  {
    name: 'children',
    path: '/children',
    children: [
      { name: 'index', path: '/' },
      { name: 'route1', path: '/route1' },
      { name: 'route2', path: '/route2' },
    ],
  },
];

export const App: Component = () => {
  const router = createRouter(routes);
  router.usePlugin(browserPlugin());
  router.start();

  return (
    <RouterProvider router={router}>
      <div class="nav">
        <Link name="index">Index</Link>
        <Link name="route1">Route1</Link>
        <Link name="route2">Route2</Link>
        <Link name="children">Children</Link>
      </div>
      <div class="content">
        <ShowRoute name="index">Index content</ShowRoute>
        <ShowRoute name="route1">Route1 content</ShowRoute>
        <ShowRoute name="route2">Route2 content</ShowRoute>
        <ShowRoute name="children">
          {/* the names inside will be auto-prefixed to `children.<NAME>` */}
          <div class="nav">
            <Link name="index">Index</Link>
            <Link name="route1">Route1</Link>
            <Link name="route2">Route2</Link>
            <Link full name="index">
              Root index
            </Link>
          </div>
          <div class="content">
            <ShowRoute name="index">Index content</ShowRoute>
            <ShowRoute name="route1">Route1 content</ShowRoute>
            <ShowRoute name="route2">Route2 content</ShowRoute>
          </div>
        </ShowRoute>
      </div>
    </RouterProvider>
  );
};
```

### Link example

Using with bulma's nav item:

```tsx
import { useRouter, Link } from '@zxlib/solid-router5';

const NavLink: typeof Link = (props) => (
  <Link
    {...(props as any)}
    classList={{
      'navbar-item': true,
      'is-tab': true,
      'is-active': useRouter().isActive(props.name, props.full),
    }}
  />
);
```

---
_Source: https://npm.io/package/@zxlib/solid-router5 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
