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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcpronovost/okp-router

v0.4.2

Published

A lightweight routing solution specifically designed for Vite-based projects with multilingual support.

Readme

okp-router · npm version npm license · made in Canada made in Québec

OKP Router is a lightweight routing solution specifically designed for Vite-based projects with multilingual support.

Features

  1. Multilingual support
    • Build-in language handling
    • URL-based language switching
    • Configurable default and supported languages
    • Automatic fallback to default language
  2. Dynamic routes
    • Nested route support
    • Parameter handling in URLs
    • Automatic 404 handling
  3. View management
    • Lazy loading of views
    • Caching of views
    • Automatic view resolution
    • Props and parameters passing

Installation

npm i @mcpronovost/okp-router

Configuration

Default Configuration

{
  defaultLang: "en",
  currentLang: "en",
  supportedLangs: ["en"],
  viewExtension: "jsx",
  routes: {},
  routeModules: undefined,
  views: {},
  viewsPath: "/src/views",
  viewsExtensions: ["jsx", "tsx"],
}

Direct Configuration

Define your routes and views directly in the configuration object.

import { initRouter } from "@mcpronovost/okp-router";

await initRouter({
  defaultLang: "en",
  currentLang: "en",
  supportedLangs: ["en", "fr"],
  viewsPath: "/src/pages",
  viewsExtensions: ["jsx", "tsx"],
  routes: {
    home: {
      view: "Home",
      paths: {
        en: "",
        fr: "",
      },
    },
    settings: {
      view: "Settings",
      paths: {
        en: "settings",
        fr: "parametres",
      },
      children: {
        edit: {
          view: "SettingsEdit",
          paths: {
            en: "settings/{settingId}/edit",
            fr: "parametres/{settingId}/modifier",
          },
        },
      },
    },
  },
  views: {
    "./views/Home.jsx": () => import("./views/Home.jsx"),
    "./views/Settings.jsx": () => import("./views/Settings.jsx"),
    "./views/Settings/Edit.tsx": () => import("./views/Settings/Edit.tsx"),
  },
});

Module-based Configuration

Use Vite's glob pattern to import routes and views from modules.

import { initRouter } from "@mcpronovost/okp-router";

await initRouter({
  defaultLang: "en",
  currentLang: "fr",
  supportedLangs: ["en", "fr"],
  viewsPath: "/src/pages",
  routeModules: import.meta.glob("./routes/**/*.js", {
    eager: true,
  }),
  views: import.meta.glob("./views/**/*.{jsx,tsx}", {
    eager: false,
  }),
});

Key Components

Route Definition

  • view: The view to display for the route.
  • paths: The paths for the route in different languages.
  • props: The props to pass to the view.
  • children: The child routes for the route.

View Management

  • Views are lazy-loaded components.
  • Configurable views extension.
  • Automatic error handling with customizable 404 page.

URL Structure

  • Format: /[lang]/[route]
    • Example: /fr/accueil
  • Fallback: /[defaultLang]/[route]
    • Example: /en/home
  • Parameter handling: /[lang]/[route]/{param}
    • Example: /en/settings/123

Example Usage

Get the current view and its parameters based on the current URL.

import { useEffect, useState } from "react";
import { getView } from "@mcpronovost/okp-router";
import Loading from "@/views/Loading";

function App() {
  const [View, setView] = useState(null);
  const [viewProps, setViewProps] = useState({});
  const [viewParams, setViewParams] = useState({});

  const initView = async () => {
    const { viewModule, props, params } = await getView();

    setViewProps(props);
    setViewParams(params);

    setView(() => viewModule.default);
  };

  useEffect(() => {
    initView();
  }, []);

  if (View) {
    return <View {...viewProps} {...viewParams} />;
  }

  return <Loading />;
}

Use the route key to get the translated URL for the current language.

import { r } from "@mcpronovost/okp-router";

export default function Home() {
  return (
    <div>
      <h1>Home</h1>
      <p>Welcome to the home page</p>
      <a href={r("devblog")}>Go to Devblog</a>
    </div>
  );
}

Use the route key to get the translated URL for a specific language.

import { getRouter } from "@mcpronovost/okp-router";

export default function Home() {
  const { r } = getRouter("fr");

  return (
    <div>
      <h1>Home</h1>
      <p>Welcome to the home page</p>
      <a href={r("devblog")}>Go to Devblog</a>
    </div>
  );
}

Switch the language of the current route.

import { switchLang } from "@mcpronovost/okp-router";

const newRoute = switchLang("fr");

Peer Dependencies

  • Vite (version 6 or higher)

License

This project is licensed under the BSD-3-Clause License.