@an-sdk/nextjs 0.0.3 → 0.0.4

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 +0 -59
  2. package/package.json +2 -6
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",
3
+ "version": "0.0.4",
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
  },
@@ -54,7 +50,7 @@
54
50
  "lint": "tsc --noEmit"
55
51
  },
56
52
  "dependencies": {
57
- "@an-sdk/react": "^0.0.2"
53
+ "@an-sdk/react": "^0.0.3"
58
54
  },
59
55
  "peerDependencies": {
60
56
  "next": ">=14.0.0",