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

@eliyya/type-routes

v2.5.4

Published

Type your Nextjs routes

Readme

type-routes

Type your routes to avoid 404 redirects or callbacks.

Just only install with

npm i @eliyya/type-routes

Configure your next.config.mjs

import { withTypeRoute } from '@eliyya/type-routes/next'

export default withTypeRoute({
    /* config options here */
})

Or run the cli to update your app's paths manually if you don't want to modify your next.config.mjs.

npx type-routes

And use in your application

import { app } from '@eliyya/type-routes'

export async function AdminPage() {
    const user = await getUser()

    if (!user) redirect(app.login())
    if (!user.admin) redirect(app())

    const adminInfo = await api(app.api.adminInfo(), { id: user.id })

    return (
        <>
            <nav>
                <Link href={app.admin.panel()}></Link>
                <Link href={app.admin.watcher()}></Link>
            </nav>
            <Dashboard info={adminInfo} />
        </>
    )
}
  • if the path is only a directory that contains more directories inside, will return an object with the directories that are found inside as properties with their respective type

    Example: src/app/user/settings/ will be converted to app.user and return { settings: ... }

  • If the path contains a page.js file or route.js file, it can be run as a function to return the string corresponding to the path

    Example: src/app/user/page.js will be converted to app.user() and return '/user/'

  • If it is a dynamic route marked by the [dirname] convention, it will be renamed to $dirname and the function will receive the parameters, this applies to your paths within it.

    Example:src/app/user/[id]/[option]/page.js will be converted to app.user.$id.$option('123', 'abc') and return '/user/123/abc/'

  • if the path is a catch-all segment marked by the convention [...dirname], it will be similar to a Dynamic Path, but it will be renamed to $$dirname

    Example:src/app/user/[...rest]/page.js will be converted to app.user.$$rest('123', 'abc') and return '/user/123/abc/'

Motivation

Creating new routes with a file-based router is so easy that sometimes we forget to update all the references in our code when a route is removed or changed.

Nextjs is taking action with the experimental typedRoutes option, however, this only works when used in Link tags, so there can be errors in runtime when using a redirect or even in references within our code.

This package solves it in a magic and comfortable way bringing the routes as safe type functions to be able to provoke an error in compilation and to avoid disasters with a simple way to use it without so much configuration.

[!IMPORTANT] You need to set type: "module" in your package.json if you use withTypeRoute() config in your next.config.mjs