cloudflare-next-intl 0.8.41 → 0.8.42
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 +18 -0
- package/dist/src/vite/build_id_asset.d.ts +2 -0
- package/dist/src/vite/build_id_asset.js +14 -0
- package/llms.txt +1 -0
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -217,6 +217,8 @@ export function customHandler(request: NextRequest) {
|
|
|
217
217
|
|
|
218
218
|
`intlMiddleware` automatically forwards `x-cf-country` and `x-cf-timezone` headers from `request.cf` so they are immediately available downstream via `next/headers`.
|
|
219
219
|
|
|
220
|
+
Header names default to `['x-cf-country', 'cf-ipcountry']` and `['x-cf-timezone', 'cf-timezone']`. You can customize them globally in `setIntlConfig({ generate: { countryHeaderNames: [...], timezoneHeaderNames: [...] } })` or per call via `getCountry(input, generate, headerNames)` / `getTimezone(input, fallback, generate, headerNames)`.
|
|
221
|
+
|
|
220
222
|
### Vinext Runtime Configuration
|
|
221
223
|
|
|
222
224
|
When deploying under [Vinext](https://github.com/cloudflare/vinext) with `cloudflare:workers`, you can pass your `env` and execution context (`ctx`) directly in `setIntlConfig`:
|
|
@@ -237,6 +239,22 @@ export default setIntlConfig({
|
|
|
237
239
|
});
|
|
238
240
|
```
|
|
239
241
|
|
|
242
|
+
#### Vite Build ID Asset Plugin (`cloudflare-next-intl/vite`)
|
|
243
|
+
|
|
244
|
+
When building client assets with Vite / Vinext for Cloudflare Workers, use `buildIdAsset` to emit the static `BUILD_ID` asset:
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
// vite.config.ts
|
|
248
|
+
import { defineConfig } from "vite";
|
|
249
|
+
import { buildIdAsset } from "cloudflare-next-intl/vite";
|
|
250
|
+
|
|
251
|
+
export default defineConfig({
|
|
252
|
+
plugins: [
|
|
253
|
+
buildIdAsset(), // reads __VINEXT_SHARED_BUILD_ID or __VINEXT_BUILD_ID
|
|
254
|
+
],
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
240
258
|
```tsx
|
|
241
259
|
// Client Components ("use client")
|
|
242
260
|
import { useLocale } from "cloudflare-next-intl/use";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function buildIdAsset(fileName = "BUILD_ID") {
|
|
2
|
+
return {
|
|
3
|
+
name: "cfni:build-id-asset",
|
|
4
|
+
apply: "build",
|
|
5
|
+
generateBundle() {
|
|
6
|
+
if (this.environment?.name !== "client")
|
|
7
|
+
return;
|
|
8
|
+
const buildId = process.env.__VINEXT_SHARED_BUILD_ID ?? process.env.__VINEXT_BUILD_ID;
|
|
9
|
+
if (!buildId)
|
|
10
|
+
return;
|
|
11
|
+
this.emitFile({ type: "asset", fileName, source: buildId });
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
package/llms.txt
CHANGED
|
@@ -27,6 +27,7 @@ other subpath can be used.
|
|
|
27
27
|
- `./db` — `withPublicDb(fn)` / `withUserDb(fn, uid?)` server-side Postgres/Drizzle context helpers (require `db` set on your `RoutingConfig`; direct Postgres or Supabase Data API with automatic PostgREST REST translation and `cfni_exec` fallback, see below).
|
|
28
28
|
- `./dbEslint` — flat-config ESLint fragment banning direct `@supabase/supabase-js`, `pg`, `postgres`, and deep `dist/` imports in application code.
|
|
29
29
|
- `./dbHelpers` — generic Drizzle SQL helper functions (`excluded`, `onConflictSet`, `ago`, `currentDate`, `windowCount`, `unnestLateral`, `ascNullsLast`, `alwaysTrue`, `lateral`, `aliasColumn`, `minOf`, `maxOf`, `roundReal`, `multiply`, `scalarFromCte`) for use with `./db`.
|
|
30
|
+
- `./vite` — `buildIdAsset(fileName?)`: Vite plugin to emit the client `BUILD_ID` asset (from `__VINEXT_SHARED_BUILD_ID` or `__VINEXT_BUILD_ID`) during build in Vinext/Vite environments.
|
|
30
31
|
|
|
31
32
|
## `firebaseAuth*` subpaths (require `firebaseAuth` set on your `RoutingConfig`)
|
|
32
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudflare-next-intl",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.42",
|
|
4
4
|
"description": "Optimized Next Intl Package Special for App Router and Cloudflare",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -209,6 +209,10 @@
|
|
|
209
209
|
"./dbSchema": {
|
|
210
210
|
"types": "./dist/src/db/schema.d.ts",
|
|
211
211
|
"import": "./dist/src/db/schema.js"
|
|
212
|
+
},
|
|
213
|
+
"./vite": {
|
|
214
|
+
"types": "./dist/src/vite/build_id_asset.d.ts",
|
|
215
|
+
"import": "./dist/src/vite/build_id_asset.js"
|
|
212
216
|
}
|
|
213
217
|
},
|
|
214
218
|
"scripts": {
|
|
@@ -264,11 +268,15 @@
|
|
|
264
268
|
"peerDependencies": {
|
|
265
269
|
"next": ">=12.0.0",
|
|
266
270
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0",
|
|
267
|
-
"typescript": ">=5.0.0"
|
|
271
|
+
"typescript": ">=5.0.0",
|
|
272
|
+
"vite": ">=6"
|
|
268
273
|
},
|
|
269
274
|
"peerDependenciesMeta": {
|
|
270
275
|
"typescript": {
|
|
271
276
|
"optional": true
|
|
277
|
+
},
|
|
278
|
+
"vite": {
|
|
279
|
+
"optional": true
|
|
272
280
|
}
|
|
273
281
|
},
|
|
274
282
|
"devDependencies": {
|
|
@@ -292,6 +300,7 @@
|
|
|
292
300
|
"tsup": "^8.5.1",
|
|
293
301
|
"typescript": "^5.5.3",
|
|
294
302
|
"typescript-eslint": "^8.33.1",
|
|
303
|
+
"vite": "^7.0.0",
|
|
295
304
|
"vitest": "^3.0.8"
|
|
296
305
|
}
|
|
297
306
|
}
|