@an-sdk/nextjs 0.0.3 → 0.0.5
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 +0 -59
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -83,65 +83,6 @@ Browser Your Next.js Server AN Relay
|
|
|
83
83
|
|<-- streaming response -----(SSE)---------------------------|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
## Adding Your Own Auth
|
|
87
|
-
|
|
88
|
-
For custom auth (Clerk, NextAuth, etc.), use `exchangeToken` directly:
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
// app/api/an/token/route.ts
|
|
92
|
-
import { auth } from "@clerk/nextjs/server"
|
|
93
|
-
import { exchangeToken } from "@an-sdk/nextjs/server"
|
|
94
|
-
|
|
95
|
-
export async function POST(req: Request) {
|
|
96
|
-
const { userId } = await auth()
|
|
97
|
-
if (!userId) {
|
|
98
|
-
return Response.json({ error: "Unauthorized" }, { status: 401 })
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const { agent } = await req.json()
|
|
102
|
-
|
|
103
|
-
const data = await exchangeToken({
|
|
104
|
-
apiKey: process.env.AN_API_KEY!,
|
|
105
|
-
agent,
|
|
106
|
-
userId,
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
return Response.json(data)
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## API
|
|
114
|
-
|
|
115
|
-
### `createAnTokenHandler(options)` — Server
|
|
116
|
-
|
|
117
|
-
Creates a Next.js `POST` route handler.
|
|
118
|
-
|
|
119
|
-
| Option | Type | Default | Description |
|
|
120
|
-
|--------|------|---------|-------------|
|
|
121
|
-
| `apiKey` | `string` | required | Your `an_sk_` API key |
|
|
122
|
-
| `relayUrl` | `string` | `"https://relay.an.dev"` | Relay API URL |
|
|
123
|
-
| `expiresIn` | `string` | `"1h"` | Token expiry |
|
|
124
|
-
|
|
125
|
-
### `exchangeToken(options)` — Server
|
|
126
|
-
|
|
127
|
-
Low-level function to exchange an API key for a JWT.
|
|
128
|
-
|
|
129
|
-
```ts
|
|
130
|
-
const { token, expiresAt } = await exchangeToken({
|
|
131
|
-
apiKey: process.env.AN_API_KEY!,
|
|
132
|
-
agent: "my-agent",
|
|
133
|
-
userId: "user-123",
|
|
134
|
-
})
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Re-exports
|
|
138
|
-
|
|
139
|
-
`@an-sdk/nextjs` re-exports everything from `@an-sdk/react`:
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
import { AnAgentChat, createAnChat, applyTheme } from "@an-sdk/nextjs"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
86
|
## License
|
|
146
87
|
|
|
147
88
|
MIT
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@an-sdk/nextjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Next.js integration for AN AI agent chat — server-side token handler",
|
|
6
6
|
"homepage": "https://an.dev",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/21st-dev/an-sdk"
|
|
10
|
-
},
|
|
11
7
|
"publishConfig": {
|
|
12
8
|
"access": "public"
|
|
13
9
|
},
|
|
@@ -53,13 +49,13 @@
|
|
|
53
49
|
"build": "tsup",
|
|
54
50
|
"lint": "tsc --noEmit"
|
|
55
51
|
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@an-sdk/react": "^0.0.2"
|
|
58
|
-
},
|
|
59
52
|
"peerDependencies": {
|
|
60
53
|
"next": ">=14.0.0",
|
|
61
54
|
"react": "^18.0.0 || ^19.0.0",
|
|
62
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
55
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
56
|
+
"@ai-sdk/react": "^2.0.0",
|
|
57
|
+
"@an-sdk/react": "^0.0.3",
|
|
58
|
+
"ai": "^5.0.0"
|
|
63
59
|
},
|
|
64
60
|
"devDependencies": {
|
|
65
61
|
"@types/react": "^19.0.0",
|