@yak-io/nextjs 0.2.0 → 0.3.1
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 +40 -7
- package/dist/internal/logger.d.ts +3 -8
- package/dist/internal/logger.d.ts.map +1 -1
- package/dist/internal/logger.js +3 -21
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
46
46
|
### 2. Unified API route
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
// app/api/yak/[...yak]/route.ts
|
|
49
|
+
// app/api/yak/[[...yak]]/route.ts
|
|
50
50
|
import { createNextYakHandler } from "@yak-io/nextjs/server";
|
|
51
51
|
|
|
52
52
|
export const { GET, POST } = createNextYakHandler({
|
|
@@ -178,11 +178,13 @@ yak-nextjs generate-manifest --pages-dir ./src/pages
|
|
|
178
178
|
yak-nextjs generate-manifest --app-dir ./app --output ./src/generated/routes.ts
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
## Route Manifest for Production
|
|
181
|
+
## Route Manifest for Production (Required)
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
> **Important:** This setup is required for production deployments. Skip this only if you are providing your own custom routes via the `routes` or `getRoutes` options.
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
During local development, routes are scanned directly from the filesystem. However, when you build your Next.js app for production, only the compiled `.next` output is included—source files like `./src/app` are not present at runtime, causing route discovery to fail.
|
|
186
|
+
|
|
187
|
+
### Required setup
|
|
186
188
|
|
|
187
189
|
1. Add a `prebuild` script to generate the manifest before Next.js builds:
|
|
188
190
|
|
|
@@ -195,18 +197,49 @@ During local development, routes are scanned directly from the filesystem—no s
|
|
|
195
197
|
}
|
|
196
198
|
```
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
The CLI auto-detects your directory structure. If your project uses non-standard paths, specify them explicitly:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"scripts": {
|
|
205
|
+
"prebuild": "yak-nextjs generate-manifest --app-dir ./app --output ./app/yak.routes.ts",
|
|
206
|
+
"build": "next build"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
| Project structure | Command |
|
|
212
|
+
|-------------------|-------------------------------------------------------|
|
|
213
|
+
| `src/app/` (default) | `yak-nextjs generate-manifest` |
|
|
214
|
+
| `app/` | `yak-nextjs generate-manifest --app-dir ./app --output ./app/yak.routes.ts` |
|
|
215
|
+
| `src/app/` + `src/pages/` | `yak-nextjs generate-manifest --pages-dir ./src/pages` |
|
|
216
|
+
| `app/` + `pages/` | `yak-nextjs generate-manifest --app-dir ./app --pages-dir ./pages --output ./app/yak.routes.ts` |
|
|
217
|
+
|
|
218
|
+
2. Add the generated file to `.gitignore`:
|
|
219
|
+
|
|
220
|
+
```gitignore
|
|
221
|
+
# Generated route manifest (use the path matching your --output)
|
|
222
|
+
src/yak.routes.ts
|
|
223
|
+
# or for root app/ directory:
|
|
224
|
+
# app/yak.routes.ts
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
3. Use the route manifest adapter in your handler:
|
|
199
228
|
|
|
200
229
|
```ts
|
|
201
|
-
// app/api/yak/[...yak]/route.ts
|
|
230
|
+
// app/api/yak/[[...yak]]/route.ts
|
|
202
231
|
import { createNextYakHandler, createRouteManifestAdapter } from "@yak-io/nextjs/server";
|
|
203
|
-
import { routes } from "@/yak.routes";
|
|
232
|
+
import { routes } from "@/yak.routes"; // Adjust path based on your tsconfig paths
|
|
204
233
|
|
|
205
234
|
export const { GET, POST } = createNextYakHandler({
|
|
206
235
|
routes: createRouteManifestAdapter({ routes }),
|
|
207
236
|
});
|
|
208
237
|
```
|
|
209
238
|
|
|
239
|
+
> **Note:** The import path depends on your `tsconfig.json` paths. Common configurations:
|
|
240
|
+
> - `src/yak.routes.ts` → `@/yak.routes` (when `@/*` maps to `./src/*`)
|
|
241
|
+
> - `app/yak.routes.ts` → `@/yak.routes` (when `@/*` maps to `./app/*`) or `../../../yak.routes`
|
|
242
|
+
|
|
210
243
|
The generated TypeScript module is imported directly, ensuring it's bundled with your serverless function automatically.
|
|
211
244
|
|
|
212
245
|
### Route filtering
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-export logger from @yak-io/javascript.
|
|
3
|
+
* All logging configuration is centralized there.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
debug: (message: string, ...args: unknown[]) => void;
|
|
7
|
-
info: (message: string, ...args: unknown[]) => void;
|
|
8
|
-
warn: (message: string, ...args: unknown[]) => void;
|
|
9
|
-
error: (message: string, ...args: unknown[]) => void;
|
|
10
|
-
};
|
|
5
|
+
export { logger } from "@yak-io/javascript";
|
|
11
6
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/internal/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/internal/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/internal/logger.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-export logger from @yak-io/javascript.
|
|
3
|
+
* All logging configuration is centralized there.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
debug: (message, ...args) => {
|
|
7
|
-
// No-op in production, could log in development
|
|
8
|
-
if (process.env.NODE_ENV === "development") {
|
|
9
|
-
console.debug(`[yak/nextjs] ${message}`, ...args);
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
info: (message, ...args) => {
|
|
13
|
-
if (process.env.NODE_ENV === "development") {
|
|
14
|
-
console.info(`[yak/nextjs] ${message}`, ...args);
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
warn: (message, ...args) => {
|
|
18
|
-
console.warn(`[yak/nextjs] ${message}`, ...args);
|
|
19
|
-
},
|
|
20
|
-
error: (message, ...args) => {
|
|
21
|
-
console.error(`[yak/nextjs] ${message}`, ...args);
|
|
22
|
-
},
|
|
23
|
-
};
|
|
5
|
+
export { logger } from "@yak-io/javascript";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yak-io/nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Next.js SDK for embedding yak chatbot with route manifest generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -60,21 +60,21 @@
|
|
|
60
60
|
"yak-nextjs": "./dist/cli/generate-manifest.js"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@yak-io/javascript": "0.
|
|
64
|
-
"@yak-io/react": "0.
|
|
63
|
+
"@yak-io/javascript": "0.4.0",
|
|
64
|
+
"@yak-io/react": "0.4.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"next": "^14.0.0 || ^15.0.0",
|
|
67
|
+
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
68
68
|
"react": "^18.0.0 || ^19.0.0",
|
|
69
69
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@types/node": "^24.10.
|
|
73
|
-
"@types/react": "^19.2.
|
|
72
|
+
"@types/node": "^24.10.4",
|
|
73
|
+
"@types/react": "^19.2.10",
|
|
74
74
|
"@types/react-dom": "^19.2.0",
|
|
75
|
-
"next": "^16.
|
|
76
|
-
"react": "^19.2.
|
|
77
|
-
"react-dom": "^19.2.
|
|
75
|
+
"next": "^16.1.6",
|
|
76
|
+
"react": "^19.2.4",
|
|
77
|
+
"react-dom": "^19.2.4",
|
|
78
78
|
"typescript": "^5.3.0",
|
|
79
79
|
"@repo/typescript-config": "0.0.0"
|
|
80
80
|
},
|