@esroute/lit
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

@esroute/lit

An integration of esroute into lit

This library provides a renderRoutes() directive to render the routes that are resolved by the router.

You can use the createRouter() factory to create the router instance.

Example

import { createRouter, renderRoutes } from "@esroute/lit";
import { html, LitElement } from "lit";
import { customElement } from "lit/decorators.js";

const router = createRouter({
  routes: {
    "": () =>
      import("./routes/root").then(() => html`<esroute-root></esroute-root>`),
    foo: {
      "*": ({ params: [name] }) =>
        import("./routes/foo").then(
          () => html`<my-greeter greeting=${name}></my-greeter>`
        ),
    },
  },
});

@customElement("my-demo")
export class Demo extends LitElement {
  render() {
    return html`${renderRoutes(router)}`;
  }
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.9.0
    43
    • latest

Version History

Package Sidebar

Install

npm i @esroute/lit

Weekly Downloads

87

Version

0.9.0

License

MIT

Unpacked Size

6.06 kB

Total Files

7

Last publish

Collaborators

  • svi3c