@yak-io/nextjs 0.3.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.
Files changed (2) hide show
  1. package/README.md +40 -7
  2. package/package.json +8 -8
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
- During local development, routes are scanned directly from the filesystem—no setup needed. 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.
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
- ### Recommended setup
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
- 2. Use the route manifest adapter in your handler:
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yak-io/nextjs",
3
- "version": "0.3.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,8 +60,8 @@
60
60
  "yak-nextjs": "./dist/cli/generate-manifest.js"
61
61
  },
62
62
  "dependencies": {
63
- "@yak-io/javascript": "0.3.0",
64
- "@yak-io/react": "0.3.0"
63
+ "@yak-io/javascript": "0.4.0",
64
+ "@yak-io/react": "0.4.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0",
@@ -69,12 +69,12 @@
69
69
  "react-dom": "^18.0.0 || ^19.0.0"
70
70
  },
71
71
  "devDependencies": {
72
- "@types/node": "^24.10.2",
73
- "@types/react": "^19.2.7",
72
+ "@types/node": "^24.10.4",
73
+ "@types/react": "^19.2.10",
74
74
  "@types/react-dom": "^19.2.0",
75
- "next": "^16.0.10",
76
- "react": "^19.2.3",
77
- "react-dom": "^19.2.3",
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
  },