@edgeone/react-router 1.0.0 → 1.0.2
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 +7 -148
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,157 +1,16 @@
|
|
|
1
|
-
# @edgeone/
|
|
1
|
+
# @edgeone/xxx
|
|
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-pages --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-pages";
|
|
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
|
-
1. Upload `.edgeone` directory
|
|
97
|
-
2. Set static path: `.edgeone/assets`
|
|
98
|
-
3. Set server entry: `.edgeone/server-handler/index.mjs`
|
|
99
|
-
|
|
100
|
-
### Docker
|
|
101
|
-
|
|
102
|
-
```dockerfile
|
|
103
|
-
FROM node:18-alpine
|
|
104
|
-
WORKDIR /app
|
|
105
|
-
COPY .edgeone .edgeone
|
|
106
|
-
EXPOSE 9000
|
|
107
|
-
CMD ["node", ".edgeone/server-handler/index.mjs"]
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Static Hosting (CSR)
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
# Vercel
|
|
114
|
-
vercel --prod .edgeone/assets
|
|
115
|
-
|
|
116
|
-
# Netlify
|
|
117
|
-
netlify deploy --prod --dir=.edgeone/assets
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Build Process
|
|
121
|
-
|
|
122
|
-
The adapter uses esbuild to bundle the server with the following optimizations:
|
|
123
|
-
|
|
124
|
-
- **Platform**: Node.js 18+
|
|
125
|
-
- **Format**: ESM
|
|
126
|
-
- **Tree-shaking**: Enabled
|
|
127
|
-
- **External**: Node.js built-in modules only
|
|
128
|
-
- **Bundle size**: ~1.88 MB (includes React, React Router, and all dependencies)
|
|
129
|
-
|
|
130
|
-
## Troubleshooting
|
|
131
|
-
|
|
132
|
-
**Build fails**: Ensure `build/client` exists. Run `npm run build` first.
|
|
133
|
-
|
|
134
|
-
**Port in use**:
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
PORT=8080 node .edgeone/server-handler/index.mjs
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Missing routes**: Enable verbose logging:
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
edgeoneAdapter({ verbose: true });
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Environment Variables
|
|
147
|
-
|
|
148
|
-
- `PORT` - Server port (default: 9000)
|
|
149
|
-
|
|
150
|
-
## Requirements
|
|
151
|
-
|
|
152
|
-
- Node.js >= 18.0.0
|
|
153
|
-
- Vite >= 5.0.0
|
|
154
|
-
- React Router >= 7.0.0
|
|
13
|
+
- Check our [Product Introduction](https://pages.edgeone.ai/document/product-introduction) for more on integrations.
|
|
155
14
|
|
|
156
15
|
## License
|
|
157
16
|
|