Skip to content

Commit ae9b000

Browse files
committed
fix: remove <Link>
1 parent ca89989 commit ae9b000

File tree

6 files changed

+7
-304
lines changed

6 files changed

+7
-304
lines changed

README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ A modern React router built on the [Navigation API](https://developer.mozilla.or
88
## Features
99

1010
- **Navigation API based** - Uses the modern Navigation API instead of the History API
11-
- **Native `<a>` tags work** - No need for special `<Link>` component for basic navigation
11+
- **Native `<a>` tags just work** - No special `<Link>` component needed; use standard HTML links
1212
- **Object-based routes** - Define routes as plain JavaScript objects
1313
- **Nested routing** - Support for layouts and nested routes with `<Outlet>`
1414
- **Type-safe** - Full TypeScript support
15-
- **Lightweight** - ~2.5 kB gzipped
15+
- **Lightweight** - Minimal API surface
1616

1717
## Installation
1818

@@ -23,15 +23,16 @@ npm install @funstack/router
2323
## Quick Start
2424

2525
```tsx
26-
import { Router, Link, Outlet, useParams } from "@funstack/router";
26+
import { Router, Outlet, useParams } from "@funstack/router";
2727
import type { RouteDefinition } from "@funstack/router";
2828

2929
function Layout() {
3030
return (
3131
<div>
3232
<nav>
33-
<Link to="/">Home</Link>
34-
<Link to="/users">Users</Link>
33+
{/* Native <a> tags work for client-side navigation */}
34+
<a href="/">Home</a>
35+
<a href="/users">Users</a>
3536
</nav>
3637
<Outlet />
3738
</div>
@@ -85,31 +86,6 @@ The root component that provides routing context.
8586
| `routes` | `RouteDefinition[]` | Array of route definitions |
8687
| `children` | `ReactNode` | Optional children rendered alongside routes |
8788

88-
#### `<Link>`
89-
90-
Navigation link component. **Unlike traditional History API-based routers, you don't need `<Link>` for basic navigation.** The Navigation API automatically intercepts native `<a>` tag clicks, so a plain `<a href="/users">Users</a>` works for client-side routing.
91-
92-
Use `<Link>` only when you need:
93-
94-
- **`state`** - Pass state data to the destination
95-
- **`replace`** - Replace history entry instead of push
96-
97-
```tsx
98-
// Basic navigation: just use <a>
99-
<a href="/users">Users</a>
100-
101-
// Need state or replace: use <Link>
102-
<Link to="/users" replace state={{ from: "home" }}>
103-
Users
104-
</Link>
105-
```
106-
107-
| Prop | Type | Description |
108-
| --------- | --------- | ------------------------------------- |
109-
| `to` | `string` | Destination URL |
110-
| `replace` | `boolean` | Replace history entry instead of push |
111-
| `state` | `unknown` | State to pass to the destination |
112-
11389
#### `<Outlet>`
11490

11591
Renders the matched child route. Used in layout components.

docs/architecture.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ const routes: RouteDefinition[] = [
141141
<Router routes={routes} />;
142142
```
143143

144-
#### `<Link>`
145-
146-
Navigation component that uses the Navigation API:
147-
148-
```tsx
149-
<Link to="/users/123">View User</Link>
150-
```
151-
152144
#### `<Outlet>`
153145

154146
Renders the matched child route in a layout component:
@@ -285,7 +277,6 @@ const currentEntry = useSyncExternalStore(
285277
src/
286278
├── index.ts # Public exports
287279
├── Router.tsx # <Router> provider component
288-
├── Link.tsx # <Link> component
289280
├── Outlet.tsx # <Outlet> component
290281
├── hooks/
291282
│ ├── useNavigate.ts

example/src/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
Router,
3-
Link,
43
Outlet,
54
useLocation,
65
useParams,
@@ -66,10 +65,7 @@ function Home() {
6665
<a href="/search?q=hello&page=1">Search parameters</a>
6766
</li>
6867
<li>
69-
<Link to="/about" state={{ from: "home" }}>
70-
Navigation with state
71-
</Link>{" "}
72-
(using &lt;Link&gt; for state)
68+
See About page for <code>useNavigate()</code> hook demo
7369
</li>
7470
</ul>
7571
</div>

src/Link.tsx

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/__tests__/Link.test.tsx

Lines changed: 0 additions & 198 deletions
This file was deleted.

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// Components
44
export { Router, type RouterProps } from "./Router.js";
5-
export { Link, type LinkProps } from "./Link.js";
65
export { Outlet } from "./Outlet.js";
76

87
// Hooks

0 commit comments

Comments
 (0)