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

@weresk/router

v0.1.2

Published

**@weresk/router** Toolkit for working with links in Next.js app

Downloads

66

Readme

@weresk/router Toolkit for working with links in Next.js app

Exports

Types

  • Schemas
    • linkTyped({router: RouterConfig, localization?: LocalizationConfig}): Link with manual selection between link types: reference, anchor, external, internal or file
    • linkExternal({router: RouterConfig, localization?: LocalizationConfig}): Link with a caption and external URL
    • linkCaptioned({router: RouterConfig, localization?: LocalizationConfig}): Link with a caption and typed link
    • linkContact({router: RouterConfig, localization?: LocalizationConfig}): Typed contact link
    • normalizedSlug({router: RouterConfig, localization?: LocalizationConfig}): Slug schema with slugify and isUnique functions set
    • routerObjects({router: RouterConfig, localization?: LocalizationConfig}): Generates an array of schema definitions with all types listed above

Types

  • Props
    • ReferenceDocument: Base Sanity document type with title, slug and optional parent
    • RouterSchemaProps: Props for router schemas definition
    • RouterConfig<DocumentType extends ReferenceDocument = ReferenceDocument>: Router config object
      • mode: "parent" | "folder": Defines what strategy is used for pages structure:
        • parent: Documents are nested under the parent document like /parents-parent/parent/slug
        • folder: Documents are grouped inside the folder determined by document type, using routes configuration, like /folder/slug
      • schemas: string[]: Link of document schemas that can be referenced in links
      • routes: Record<DocumentType["_type"], string>: Object with document types as keys and folder names as values to use in folder mode
      • contacts?: ContactType[]: Optional customization of contacts types for linkContact schema
      • parentDepth?: number: Optional customization of nesting depth limit used in parent mode

Contants

  • contactTypeList: List of contact types

Utils

  • getDocumentPath(doc: ReferenceDocument | undefined, config: RouterConfig): string: Generates URL for a document
  • getLinkType(url: string): LinkType: Checks the link type for a URL
  • getTypesWithSameRoute(docType: string | undefined, routes: Record<string, string>): string[]: Finds the documents types that have the route similar to a singular document type
  • isUniqueSlugFunction(config: RouterConfig): (slug: string, context: SlugValidationContext) => Promise<boolean>: Generates isUniqueSlug function based on router config
  • normalizeLink(input: string): string: Normalizes a string to be used as a URL
  • prepareLink(input: LinkTyped, router: RouterConfig, lang?: IsoLocale): string: Generates an URL from a LinkTyped object
  • toLinkCaptioned<Reference extends ReferenceDocument = ReferenceDocument>(doc: Reference): LinkCaptioned<NonNullable<Reference["title"]>, LinkTyped<Reference>>: Converts a document type into LinkCaptioned
  • wrapReference(doc: ReferenceDocument): LinkTyped: Converts a document type into LinkTyped

Components

  • LinkWrapper: A wrapper function to render a Next.js link from router schemas like typed link, reference and href
    • Props: LinkWrapperProps extends LocaleProps<DefaultPropsWithChildren>
      • href?: string: URL, is set used first
      • reference?: ReferenceDocument: Refefence to a document, if set used before the link
      • link?: LinkTyped: Typed link
      • title?: string: title property for rendered HTML element
      • config: RouterConfig: Router configuration
  • ContactLink: Renders contact link as a text or as an icon
    • Props: ContactLinkProps extends LocaleProps<DefaultProps>
      • link: LinkContact: Contact type identifier
      • mode: "text" | "icon": Render mode
      • config: RouterConfig: Router configuration