Skip to content

aymericzip/intlayer-skills / skills/intlayer-solid

intlayer-solid

Verified

Integrates Intlayer internationalization with SolidJS components. Use when the user asks to "setup SolidJS i18n", create a new translated component, use the "useIntlayer" hook in Solid, or configure providers.

references/packages_solid-intlayer_useRewriteURL.md

View on GitHub
---
updatedAt: 2026-09-27
priority: 5
createdAt: 2025-08-23
title: "useRewriteURL Hook Documentation | solid-intlayer"
description: "Use useRewriteURL in SolidJS to rewrite the browser URL to its localized version, following the custom URL rewrites of your configuration."
keywords:
  - useRewriteURL
  - solid-intlayer
  - solidjs
  - internationalization
  - i18n
slugs:
  - doc
  - packages
  - solid-intlayer
  - useRewriteURL
author: aymericzip
---

# useRewriteURL Hook

The `useRewriteURL` hook for SolidJS is designed to manage localized URL rewrites on the client side. It automatically corrects the browser's URL to its "pretty" localized version based on the current locale and the configuration in `intlayer.config.ts`.

By using `window.history.replaceState`, it avoids redundant Solid Router navigations.

## Usage

Call the hook within a component that is part of your application.

```tsx
import { useRewriteURL } from "solid-intlayer";

const Layout = (props) => {
  // Automatically correct /fr/tests to /fr/essais in the address bar if a rewrite rule exists
  useRewriteURL();

  return <>{props.children}</>;
};
```

## How it works

1. **Detection**: The hook uses `createEffect` to monitor changes in the reactive `locale()`.
2. **Matching**: It identifies if the current `window.location.pathname` corresponds to a canonical route that has a prettier localized alias for the current language.
3. **URL Correction**: If a prettier alias is found, the hook calls `window.history.replaceState` to update the address bar without affecting the internal navigation state or causing component re-renders.

## Why use it?

- **Authoritative URLs**: Enforces a single URL for each localized version of your content, which is crucial for SEO.
- **Developer Convenience**: Allows you to keep your internal route definitions canonical while exposing user-friendly, localized paths to the outside world.
- **Consistency**: Corrects URLs when users manually type a path that doesn't follow your preferred localization rules.

---
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall