@palbase/web 5.0.1 → 6.0.0
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 +15 -15
- package/dist/{chunk-QKFPPZLF.js → chunk-KOJ4OAAR.js} +2 -2
- package/dist/{chunk-QKFPPZLF.js.map → chunk-KOJ4OAAR.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/next/{middleware.cjs → proxy.cjs} +11 -11
- package/dist/next/proxy.cjs.map +1 -0
- package/dist/next/{middleware.d.cts → proxy.d.cts} +32 -31
- package/dist/next/{middleware.d.ts → proxy.d.ts} +32 -31
- package/dist/next/{middleware.js → proxy.js} +6 -6
- package/dist/next/proxy.js.map +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +7 -7
- package/dist/next/middleware.cjs.map +0 -1
- package/dist/next/middleware.js.map +0 -1
package/README.md
CHANGED
|
@@ -49,10 +49,10 @@ If you forget to import it, every `pb` call throws a guided `BackendError`
|
|
|
49
49
|
|
|
50
50
|
## Calling your backend
|
|
51
51
|
|
|
52
|
-
Codegen turns each backend controller into a typed namespace on `pb`.
|
|
53
|
-
controller
|
|
54
|
-
|
|
55
|
-
body/query second:
|
|
52
|
+
Codegen turns each backend controller into a typed namespace on `pb`. The
|
|
53
|
+
operation id is `<controller>.<method>` — `TodosController.create` becomes
|
|
54
|
+
`pb.todos.create(input)`, `HelloController.greet` becomes `pb.hello.greet()`.
|
|
55
|
+
Path params come first, the request body/query second:
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
58
|
import { pb } from '@palbase/web';
|
|
@@ -206,8 +206,8 @@ specific failures a given endpoint documents.
|
|
|
206
206
|
## Next.js — `@palbase/web/next`
|
|
207
207
|
|
|
208
208
|
The Next.js App Router adapter shares one session cookie between the browser and
|
|
209
|
-
the server so Server Components, Route Handlers and
|
|
210
|
-
auth state.
|
|
209
|
+
the server so Server Components, Route Handlers and the proxy all see the same
|
|
210
|
+
auth state. Requires `next >= 16` (the `proxy` file convention).
|
|
211
211
|
|
|
212
212
|
**1. Configure the browser client** (a client provider/component):
|
|
213
213
|
|
|
@@ -225,15 +225,15 @@ export function PalbeProvider({ children }: { children: React.ReactNode }) {
|
|
|
225
225
|
`setupPalbeNext()` swaps in `cookieSessionStorage` so the session is written to a
|
|
226
226
|
cookie the server can read.
|
|
227
227
|
|
|
228
|
-
**2. Refresh the session in
|
|
228
|
+
**2. Refresh the session in the proxy** (required for session-bearing RSC apps):
|
|
229
229
|
|
|
230
230
|
```ts
|
|
231
|
-
//
|
|
232
|
-
import {
|
|
231
|
+
// proxy.ts
|
|
232
|
+
import { palbeProxy } from '@palbase/web/next/proxy';
|
|
233
233
|
import type { NextRequest } from 'next/server';
|
|
234
234
|
|
|
235
|
-
export function
|
|
236
|
-
return
|
|
235
|
+
export function proxy(request: NextRequest) {
|
|
236
|
+
return palbeProxy(request, {
|
|
237
237
|
url: 'https://<environmentRef>.palbase.studio',
|
|
238
238
|
apiKey: 'pb_<environmentRef>_c...',
|
|
239
239
|
});
|
|
@@ -247,15 +247,15 @@ export const config = { matcher: ['/((?!_next/static|_next/image|favicon.ico).*)
|
|
|
247
247
|
|
|
248
248
|
Two rules the shape above encodes:
|
|
249
249
|
|
|
250
|
-
- **Import `@palbase/web/next/
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
- **Import `@palbase/web/next/proxy`, not `@palbase/web/next`.** Next compiles
|
|
251
|
+
the proxy into its own bundle, and the full adapter graph reaches
|
|
252
|
+
`livekit-client` and the MLS WASM loader — megabytes on every request path.
|
|
253
253
|
This entry reaches none of it.
|
|
254
254
|
- **Pass the config explicitly; do not `import './palbe.gen'` here.** That
|
|
255
255
|
import would pull the same graph back in. It also means `config`/`matcher`
|
|
256
256
|
must be declared in this file — Next reads `export const config` off this
|
|
257
257
|
file's own AST, so a re-exported or imported one is silently ignored and the
|
|
258
|
-
|
|
258
|
+
proxy degrades to matching every request.
|
|
259
259
|
|
|
260
260
|
**3. Read data in Server Components** with `pbServer()` — a per-request,
|
|
261
261
|
session-isolated client:
|
|
@@ -8633,7 +8633,7 @@ function defaultSessionStorage(key) {
|
|
|
8633
8633
|
}
|
|
8634
8634
|
|
|
8635
8635
|
// src/version.ts
|
|
8636
|
-
var VERSION = "
|
|
8636
|
+
var VERSION = "6.0.0";
|
|
8637
8637
|
|
|
8638
8638
|
// src/runtime.ts
|
|
8639
8639
|
function buildRuntime(config) {
|
|
@@ -9058,4 +9058,4 @@ export {
|
|
|
9058
9058
|
pb,
|
|
9059
9059
|
createBoundClient
|
|
9060
9060
|
};
|
|
9061
|
-
//# sourceMappingURL=chunk-
|
|
9061
|
+
//# sourceMappingURL=chunk-KOJ4OAAR.js.map
|