Socket
Socket
Sign inDemoInstall

lit-routing

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lit-routing

A lightweight routing library for lit-html.


Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Install size
15.5 kB
Created
Weekly downloads
 

Readme

Source

Lit Routing 🔥

A lightweight wrapper for routing in lit-html apps. This library works with any routing library, if you provide a corresponding connector. A connector for the lightweight router Navigo is already provided.

Installing

Using npm:
npm i -S lit-routing

Using yarn:
yarn add lit-routing

Additionally, you need to install the routing library of your choice, e.g.:
npm i -S navigo
yarn add navigo

Usage

This library consists of a global Router object and a LitRouter component. First, you need to configure the router.

import {html} from 'lit-html';
import {Router, RouteConfig} from 'lit-routing';
import {NavigoConnector} from 'lit-routing/lib/connectors/navigo';

const routes: RouteConfig[] = [
  {path: '', template: document.createElement('button')},
  {path: '/settings', template: new SettingsPage()}, // <- suppose this is a LitElement / web component
  {path: '**', template: html`404 - not found`},
];

Router.initialize(NavigoConnector, routes, {useHash: true})

A route template can either be a lit-html template literal or a HTML element / web component. In order to provide a fallback route, a route with path '**' can be added as the last route.

Afterwards, you only need to use the <lit-router> element, where you want your routes to be displayed.

FAQs

Last updated on 14 Sep 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc