aymericzip/intlayer-skills / skills/intlayer-svelte
intlayer-svelte
VerifiedIntegrates Intlayer internationalization with Svelte and SvelteKit applications. Use when the user asks to "setup Svelte i18n", create a new translated component, use the "useIntlayer" store, or configure providers.
| File | Kind | Size |
|---|---|---|
| LICENCE.md | markdown | 10.7 KB |
| SKILL.md | skill md | 3.1 KB |
| references/compiler.md | markdown | 14.6 KB |
| references/concept_collections.md | markdown | 5.6 KB |
| references/concept_variants.md | markdown | 20.9 KB |
| references/environment_astro_svelte.md | markdown | 37.9 KB |
| references/environment_sveltekit.md | markdown | 36.2 KB |
| references/environment_vite-and-svelte.md | markdown | 38.6 KB |
| references/formatters.md | markdown | 17.3 KB |
| references/packages_intlayer_exports.md | markdown | 12.4 KB |
| references/packages_svelte-intlayer_exports.md | markdown | 4.4 KB |
| references/packages_svelte-intlayer_usePathname.md | markdown | 3.1 KB |
| references/packages_svelte-intlayer_useRewriteURL.md | markdown | 1.9 KB |
references/packages_svelte-intlayer_useRewriteURL.md
View on GitHub---
updatedAt: 2026-09-27
priority: 5
createdAt: 2025-08-23
title: "useRewriteURL Hook Documentation | svelte-intlayer"
description: "Use useRewriteURL in Svelte to rewrite the browser URL to its localized version, following the custom URL rewrites of your configuration."
keywords:
- useRewriteURL
- svelte-intlayer
- svelte
- sveltekit
- internationalization
- i18n
slugs:
- doc
- packages
- svelte-intlayer
- useRewriteURL
author: aymericzip
---
# useRewriteURL Hook
The `useRewriteURL` hook for Svelte 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`.
It updates the URL silently using `window.history.replaceState`, avoiding full SvelteKit navigations.
## Usage
Call the hook within a Svelte component.
```svelte
<script>
import { useRewriteURL } from "svelte-intlayer";
// Automatically correct /fr/tests to /fr/essais in the address bar if a rewrite rule exists
useRewriteURL();
</script>
<slot />
```
## How it works
1. **Reactive Updates**: The hook subscribes to the Intlayer `locale` store.
2. **Detection**: Whenever the locale changes (or on mount), it calculates if the current `window.location.pathname` has a prettier localized alias defined in your rewrite rules.
3. **URL Correction**: If a prettier path is found, the hook calls `window.history.replaceState` to update the address bar without a full page reload or triggering SvelteKit navigation logic.
## Why use it?
- **SEO Best Practices**: Ensures search engines index only the pretty, localized version of your URLs.
- **Improved UX**: Corrects manually entered URLs to reflect your preferred naming structure.
- **Silent Updates**: Modifies the address bar without affecting the component tree or navigation history.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |