@mastra/next 0.2.22-alpha.6 → 0.2.22-alpha.8
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 +50 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @mastra/next
|
|
2
|
+
|
|
3
|
+
`@mastra/next` exposes a Mastra instance through Next.js App Router route handlers. Use it to serve Mastra's REST, streaming, custom API, MCP, and A2A endpoints from the same serverless deployment as a Next.js application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Create a catch-all App Router route at `app/api/[...mastra]/route.ts`:
|
|
14
|
+
|
|
15
|
+
```typescript title="app/api/[...mastra]/route.ts"
|
|
16
|
+
import { createNextRouteHandler } from '@mastra/next';
|
|
17
|
+
import { mastra } from '../../../src/mastra';
|
|
18
|
+
|
|
19
|
+
export const { GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD } = createNextRouteHandler({
|
|
20
|
+
mastra,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The route prefix and catch-all location must match. For a route mounted below `/api/mastra`, pass the same prefix:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
createNextRouteHandler({
|
|
28
|
+
mastra,
|
|
29
|
+
prefix: '/api/mastra',
|
|
30
|
+
tools: { customTool },
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
`createNextRouteHandler()` returns handlers for every HTTP method supported by the Mastra server. It initializes the underlying Hono adapter on the first request, so the handler object can be exported synchronously from the route module.
|
|
37
|
+
|
|
38
|
+
The adapter reads the server configuration from the Mastra instance, including custom API routes, route authentication settings, MCP options, and `bodySizeLimit`. Next.js deployments default to a 4.5 MB request body limit unless the Mastra server configuration overrides it.
|
|
39
|
+
|
|
40
|
+
Use the `tools` option to register additional server tools that are not already part of the Mastra instance. The `prefix` defaults to `/api` and must correspond to the URL segment before the App Router catch-all parameter.
|
|
41
|
+
|
|
42
|
+
Authentication and custom route `requiresAuth` settings are forwarded to the shared Mastra Hono server adapter. An in-memory task store backs A2A task operations, so use this adapter with the lifecycle and persistence constraints of the target Next.js hosting environment in mind.
|
|
43
|
+
|
|
44
|
+
## Changelog
|
|
45
|
+
|
|
46
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/server-adapters/next/CHANGELOG.md) for version history and release notes.
|
|
47
|
+
|
|
48
|
+
## Support
|
|
49
|
+
|
|
50
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/next",
|
|
3
|
-
"version": "0.2.22-alpha.
|
|
3
|
+
"version": "0.2.22-alpha.8",
|
|
4
4
|
"description": "Mastra Next.js server adapter — drop your Mastra instance into a Next.js app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@mastra/server": "1.64.0-alpha.
|
|
24
|
-
"@mastra/hono": "1.7.6-alpha.
|
|
23
|
+
"@mastra/server": "1.64.0-alpha.8",
|
|
24
|
+
"@mastra/hono": "1.7.6-alpha.8"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "22.20.1",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"tsdown": "0.22.9",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vitest": "4.1.10",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@mastra/core": "1.64.0-alpha.
|
|
35
|
-
"@internal/
|
|
33
|
+
"@internal/lint": "0.0.129",
|
|
34
|
+
"@mastra/core": "1.64.0-alpha.8",
|
|
35
|
+
"@internal/types-builder": "0.0.104"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@mastra/core": ">=1.50.0-0 <2.0.0-0",
|