@edgeone/react-router 1.0.1 → 1.0.3
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 +6 -109
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,119 +1,16 @@
|
|
|
1
1
|
# @edgeone/react-router
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This adapter allows React Router to deploy your hybrid or server rendered site to [EdgeOne Pages](https://pages.edgeone.ai/).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Documentation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- ✅ **Server Bundling** - Bundles server code into a single file (SSR mode)
|
|
9
|
-
- ✅ **Route Metadata Generation** - Generates `meta.json` configuration
|
|
10
|
-
- ✅ **Multi-Mode Support** - CSR, SSR, and Hybrid (SSR + Prerender)
|
|
11
|
-
- ✅ **Tree-Shaking** - Removes unused code automatically
|
|
12
|
-
- ✅ **Zero External Dependencies** - Bundled file requires only Node.js built-ins
|
|
7
|
+
Read the [`@edgeone/react-router` docs](https://pages.edgeone.ai/document/framework-react-router)
|
|
13
8
|
|
|
14
|
-
##
|
|
9
|
+
## Support
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
npm install @edgeone/react-router --save-dev
|
|
18
|
-
```
|
|
11
|
+
- Get help in the [EdgeOne Pages Discord](https://discord.com/invite/KpdcJ8xbq6).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Add the plugin to `vite.config.ts`:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { reactRouter } from "@react-router/dev/vite";
|
|
26
|
-
import { edgeoneAdapter } from "@edgeone/react-router";
|
|
27
|
-
import { defineConfig } from "vite";
|
|
28
|
-
|
|
29
|
-
export default defineConfig({
|
|
30
|
-
plugins: [reactRouter(), edgeoneAdapter()],
|
|
31
|
-
});
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Build your project:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm run build
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Output structure:
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
.edgeone/
|
|
44
|
-
├── assets/ # Static assets
|
|
45
|
-
├── server-handler/ # Server code (SSR only)
|
|
46
|
-
│ └── index.mjs # Single-file server
|
|
47
|
-
└── meta.json # Route metadata
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Rendering Modes
|
|
51
|
-
|
|
52
|
-
### CSR (Client-Side Rendering)
|
|
53
|
-
|
|
54
|
-
Configure in `react-router.config.ts`:
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
export default { ssr: false } satisfies Config;
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Deploy to any static hosting:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npx serve .edgeone/assets
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### SSR (Server-Side Rendering)
|
|
67
|
-
|
|
68
|
-
Configure in `react-router.config.ts`:
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
export default { ssr: true } satisfies Config;
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Run locally:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
node .edgeone/server-handler/index.mjs
|
|
78
|
-
# Server at http://localhost:9000
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Hybrid (SSR + Prerender)
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
export default {
|
|
85
|
-
ssr: true,
|
|
86
|
-
async prerender() {
|
|
87
|
-
return ["/", "/about"];
|
|
88
|
-
},
|
|
89
|
-
} satisfies Config;
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Deployment
|
|
93
|
-
|
|
94
|
-
### EdgeOne Platform
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
edgeone pages deploy
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Learn more about [EdgeOne CLI](https://pages.edgeone.ai/document/edgeone-cli).
|
|
101
|
-
|
|
102
|
-
## Build Process
|
|
103
|
-
|
|
104
|
-
The adapter uses esbuild to bundle the server with the following optimizations:
|
|
105
|
-
|
|
106
|
-
- **Platform**: Node.js 18+
|
|
107
|
-
- **Format**: ESM
|
|
108
|
-
- **Tree-shaking**: Enabled
|
|
109
|
-
- **External**: Node.js built-in modules only
|
|
110
|
-
- **Bundle size**: ~1.88 MB (includes React, React Router, and all dependencies)
|
|
111
|
-
|
|
112
|
-
## Requirements
|
|
113
|
-
|
|
114
|
-
- Node.js >= 18.0.0
|
|
115
|
-
- Vite >= 5.0.0
|
|
116
|
-
- React Router >= 7.0.0
|
|
13
|
+
- Check our [Product Introduction](https://pages.edgeone.ai/document/product-introduction) for more on integrations.
|
|
117
14
|
|
|
118
15
|
## License
|
|
119
16
|
|