npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@exalt/router

v1.1.0

Published

A simple client side router for exalt apps

Downloads

36

Readme

Exalt Router

A simple client side router for exalt apps.

Actions License Donate Follow Us


Installation

You can install @exalt/router using npm:

npm install @exalt/router

Getting Started

@exalt/router comes with 3 components to handle client side routing.

  • exalt-router
  • exalt-route
  • exalt-link
  • exalt-redirect

Exalt Router

The exalt-router component is used to handle all the routing. It parses the routes behehind the scenes and will use push state routing by default. If you want to use hash routing, you can set the hash attribute to enable it.

If you want to programatically change the route, ExaltRouter exposes a static navigate method.

import { ExaltRouter } from "@exalt/router";

ExaltRouter.navigate("/about");

Exalt Route

The exalt-route component is used to define a route and assign a component to it. It takes two attributes, url and component.

Parameters are path fragments that are prefixed with a colon and if you want the parameter to be optional you can end it with a question mark. Any route parameters get passed as attributes on the rendered component.

When defining a default route to render if there is no match, just omit the url attribute.

When you want to split the bundle at the route level, you can add an onresolve event.

html`<exalt-route url="/" component="home-page" onresolve=${() => import("@pages/home-page")} />`

Example

<exalt-router>
    <exalt-route url="/" component="home-page" />
    <exalt-route url="/about" component="about-page" />
    <exalt-route url="/about/:topic?" component="about-page" />
    <exalt-route component="not-found" />
</exalt-router>

Exalt Link

The exalt-link component is used to wrap an anchor tag and change its default behavior to use client side routing. This ensures that in server side rendered environments the routing still works without JavaScript. The exalt-link component only takes a url attribute which is passed as an href attribute to the child anchor tag.

Example

<exalt-link url="/about">
    <a>About<a>
</exalt-link>

The anchor tag does not need to be a direct child of the exalt-link component, the component will just grab the first anchor tag it finds and enable client side rendering on it.

Exalt Redirect

The exalt-redirect component is used to conditionally redirect to another page or website. As soon as the component is rendered it will determine how to redirect based on the url attribute and then the page will be redirected.

Example

<exalt-redirect url="/redirect-route" />

Reporting Issues

If you are having trouble getting something to work with exalt or run into any problems, you can create a new issue.

If this framework does not fit your needs or is missing a feature you would like to see, let us know! We would greatly appreciate your feedback on it.


License

Exalt Router is licensed under the terms of the MIT license.