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

vike-i18n-routing

v0.1.31

Published

Vike plugin for i18n routing with locale prefixes and translated URLs

Downloads

438

Readme

vike-i18n-routing

Add multiple languages to your Vike app without duplicating pages

NPM Version NPM Downloads License

DocumentationQuick StartAPI

[!WARNING] This library is already usable in real projects, but it is still not battle-tested across a wide range of production setups. Use it deliberately and validate the behavior against your routing, i18n, and deployment edge cases.


Declare your locales and routes in config — the plugin handles routing, redirects, locale detection, localized links, SEO alternates, and more.

// pages/+config.ts
import vikeVue from 'vike-vue/config'
import vikeI18n from 'vike-i18n-routing/config'
import type { Config } from 'vike/types'
import type { I18nConfig } from 'vike-i18n-routing'

export default {
  extends: [vikeVue, vikeI18n],

  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'ru'],
    routes: {
      '/about': { en: '/about', ru: '/o-nas' },
    },
  } satisfies I18nConfig,
} satisfies Config
  • Resolves /ru/o-nas → page about, locale ru
  • Resolves /en/about → page about, locale en
  • Redirects /about/en/about (missing prefix)
  • Redirects /ru/about/ru/o-nas (wrong-locale URL)
  • Detects locale from URL, query param, cookie, session, Accept-Language
  • Provides localizePath() for building locale-aware links
  • Generates alternateUrls for SEO hreflang tags

Your page files stay at canonical paths — one file per page, no duplication:

pages/
  about/+Page.vue     ← serves /en/about AND /ru/o-nas

Setup

pnpm add vike-i18n-routing

See Quick Start for full setup instructions.

Using locale in components

In components, get pageContext from your framework's hook and pass it to useI18nRoute:

Vue:

import { usePageContext } from 'vike-vue/usePageContext'
import { useI18nRoute } from 'vike-i18n-routing'

const { i18nRoute, localizePath } = useI18nRoute(usePageContext())
<!-- Always pass the canonical route key, not the localized URL -->
<a :href="localizePath('/about')">About</a>
<a :href="localizePath('/about', 'ru')">О нас</a>

React:

import { usePageContext } from 'vike-react/usePageContext'
import { useI18nRoute } from 'vike-i18n-routing'

const { i18nRoute, localizePath } = useI18nRoute(usePageContext())

This package handles routing only. For translating text content use vue-i18n, react-intl, or any other i18n library alongside it.

More features

Translated URL slugs — not just the path shape, but the param values too:

// pages/+config.ts
export default {
  // ...
  i18n: {
    // ...
    routes: {
      '/services/:category': {
        en: '/services/:category',
        ru: '/uslugi/:category',
      },
    },
  } satisfies I18nConfig,
} satisfies Config
// in data loader — register per-item slug variants
setRouteParamVariants('category', { en: 'web-development', ru: 'veb-razrabotka' })
// /ru/uslugi/web-development now auto-redirects to /ru/uslugi/veb-razrabotka

Config-level redirects — locale-aware, supports path-to-regexp patterns:

// pages/+config.ts
export default {
  // ...
  i18n: {
    // ...
    redirects: {
      '/old-about': '/about',                                       // applies to all locales
      '/medicines/:country': '/drugs/:country',                     // transfers named params
      '/old-page': { url: '/about', locales: ['en'] },             // locale-scoped
    },
  } satisfies I18nConfig,
} satisfies Config

Route aliases — serve a page at an additional URL without a redirect:

// pages/+config.ts
export default {
  // ...
  i18n: {
    // ...
    aliases: {
      '/company': '/about',                          // simple — renders /about at /company
      '/spain/about': {                              // localized — own paths per locale
        target: '/about',
        en: '/spain/about',
        ru: '/spain/o-nas',
      },
      '/blog/:country/:slug': '/blog/:slug',         // parametric — extra URL segment
    },
  } satisfies I18nConfig,
} satisfies Config

Multi-domain — different locale sets and default locales per domain:

// pages/+config.ts
export default {
  // ...
  i18n: {
    // ...
    domains: {
      'site.com': { defaultLocale: 'en', locales: ['en', 'ru'] },
      'site.fr':  { defaultLocale: 'fr', locales: ['fr', 'en'], prefixDefaultLocale: false },
    },
  } satisfies I18nConfig,
} satisfies Config

Locale detection — automatically from URL prefix, query param (?locale=ru), cookie, session, or Accept-Language header.

SEOi18nRoute.alternateUrls gives you all locale URLs for <link rel="alternate" hreflang> tags.

Documentation

Full docs with API reference, all config options, and recipes:

vad1ym.github.io/vike-i18n-routing

License

MIT