שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Add usePathname utility"v10.0.023.6.2026
- "Init history"v8.2.022.6.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
Solid Integration: usePathname Hook Documentation
The usePathname hook returns the current browser pathname with the locale segment stripped, as a Solid Accessor<string>. It is useful for building locale-aware navigation (for example, determining which nav item is active) without having to manually remove the locale prefix.
Importing usePathname in Solid
העתקת הקוד ללוח
Overview
usePathname creates a reactive signal initialized from window.location.pathname, strips the locale prefix via getPathWithoutLocale, and updates the signal whenever the browser fires a popstate event (back/forward navigation). The event listener is cleaned up automatically via onCleanup.
Usage
העתקת הקוד ללוח
Return Value
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Type | Description |
|---|---|
Accessor<string> | Solid accessor (reactive getter) returning the current pathname without the locale prefix. |
Behavior
- Locale stripping: Removes the leading locale segment (e.g.
/fr/dashboard→/dashboard). - Reactive: Updates automatically on
popstateevents (browser back / forward navigation). - SSR-safe: Returns
""whenwindowis not available. - Cleanup: The
popstatelistener is removed automatically via Solid'sonCleanup.
Example
העתקת הקוד ללוח
