clear-react-router 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ It provides first-class support for:
19
19
  * Simple, provider-free architecture
20
20
  * Small, explicit API
21
21
 
22
- > 👉 TL;DR? **[Try the live playground](https://clear-react-router.vercel.app/playground)** — no setup, click around.
22
+ > TL;DR? **[Try the live playground](https://clear-react-router.vercel.app/playground)** — no setup, click around.
23
23
 
24
24
 
25
25
  ## Features
@@ -39,6 +39,23 @@ It provides first-class support for:
39
39
  - **Browser History** - Full support for browser back/forward buttons
40
40
  - **Context-aware** - Pass and update context through routes
41
41
 
42
+ ## Deployment (static hosting)
43
+
44
+ The router uses the History API (`pushState` + `popstate`) exclusively — there is no hash mode.
45
+ Deep links and page refreshes therefore need an SPA fallback on static hosts: every path must serve `index.html`, otherwise refreshing e.g. `/about` returns 404.
46
+
47
+ Vercel (`vercel.json`):
48
+
49
+ ```json
50
+ { "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
51
+ ```
52
+
53
+ Netlify (`public/_redirects`):
54
+
55
+ ```text
56
+ /* /index.html 200
57
+ ```
58
+
42
59
  ## API
43
60
 
44
61
  ### `Router`
@@ -68,6 +85,8 @@ It provides first-class support for:
68
85
 
69
86
  ### `createRouter(routes)`
70
87
 
88
+ Required: `<Router>` expects the output of `createRouter` (`RouteItem[]` with built `pattern`s and resolved lazy components), not the raw config you write. Skipping it breaks nested-path matching and lazy preloading.
89
+
71
90
  Normalizes route configuration. Extracts dynamic params, builds nested paths.
72
91
 
73
92
  | Property | Type | Description |
@@ -125,6 +144,12 @@ If a route is both `optimistic` and has `gcTime` set, keep in mind the cached sn
125
144
 
126
145
  Component for client-side navigation with prefetch support, active state detection, and pending state styling. Prefetch includes lazy route component preload.
127
146
 
147
+ `Link` (like every router hook) works outside `<Router>` — all state lives in a global store, there is no React context. Only back/forward-button handling needs a mounted `<Router>`.
148
+
149
+ Rule of thumb: `to` for plain URLs, `path` + `params` when you want the pattern checked and segments URL-encoded.
150
+
151
+ Active matching: `'/'` matches only exactly `'/'`; any other target is active on exact match or — with the default `exact={false}` — on nested URLs too (`/settings` is active at `/settings/profile`).
152
+
128
153
  | Prop | Type | Default | Description |
129
154
  |------|------|---------|-------------|
130
155
  | `to` | `string` | required (unless `path` is set) | Target path as a raw URL. Mutually exclusive with `path` |
@@ -583,7 +608,7 @@ const App = () => <Router routes={routes} errorBoundary={ErrorBoundary} />
583
608
 
584
609
  ### `useNavigate()`
585
610
 
586
- Returns a function to navigate programmatically. Accepts a string (pathname, optionally with a `?query`), a `NavigationLocation` object, or `-1` to go back.
611
+ Returns a function to navigate programmatically. Accepts a string (pathname, optionally with a `?query`), a `NavigationLocation` object (`pathname`, or typed `path` + `params` — see below), or `-1` to go back.
587
612
 
588
613
  ```tsx
589
614
  type NavigationLocation = { pathname: string; search?: string | Record<string, string | number | boolean | null | undefined>; state?: unknown }
package/dist/index.d.ts CHANGED
@@ -14,5 +14,5 @@ export { useSubmitAction } from './hooks/useSubmitAction';
14
14
  export { useRestoreScroll } from './hooks/useRestoreScroll';
15
15
  export { createRouter } from './creators/createRouter';
16
16
  export { lazy } from './utils/lazy';
17
- export type { RouteItem, BlockerState, Location, RouterProps, NavigationLocation, NavigatePathArg, PathParams, ParamsFor, Status, } from './types';
17
+ export type { RouteItem, ClientRouteItem, BlockerState, Location, RouterProps, NavigationLocation, NavigatePathArg, PathParams, ParamsFor, Status, } from './types';
18
18
  export type { ElementProps, LinkProps } from './components/Link';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear-react-router",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "A lightweight routing library for React applications",
5
5
  "author": "Andrew Bubnov",
6
6
  "scripts": {