@solvapay/next 1.0.0-preview.10 → 1.0.0-preview.11

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 CHANGED
@@ -257,10 +257,54 @@ This package is separate from `@solvapay/server` to keep the server package fram
257
257
 
258
258
  ## Middleware Setup
259
259
 
260
- These helpers expect the user ID to be set in the `x-user-id` header by your Next.js middleware:
260
+ These helpers expect the user ID to be set in the `x-user-id` header by your Next.js middleware/proxy.
261
+
262
+ ### Quick Setup with Supabase
263
+
264
+ The easiest way is to use `createSupabaseAuthMiddleware`:
265
+
266
+ **For Next.js 15:**
267
+ ```typescript
268
+ // middleware.ts (at project root)
269
+ import { createSupabaseAuthMiddleware } from '@solvapay/next';
270
+
271
+ export const middleware = createSupabaseAuthMiddleware({
272
+ publicRoutes: ['/api/list-plans'],
273
+ });
274
+
275
+ export const config = {
276
+ matcher: ['/api/:path*'],
277
+ };
278
+ ```
279
+
280
+ **For Next.js 16 with `src/` folder:**
281
+ ```typescript
282
+ // src/proxy.ts (in src/ folder, not project root)
283
+ import { createSupabaseAuthMiddleware } from '@solvapay/next';
284
+
285
+ // Use 'proxy' export for Next.js 16 (no deprecation warning)
286
+ export const proxy = createSupabaseAuthMiddleware({
287
+ publicRoutes: ['/api/list-plans'],
288
+ });
289
+
290
+ export const config = {
291
+ matcher: ['/api/:path*'],
292
+ };
293
+ ```
294
+
295
+ **File Location Notes:**
296
+ - **Next.js 15**: Place `middleware.ts` at project root
297
+ - **Next.js 16 without `src/` folder**: Place `middleware.ts` or `proxy.ts` at project root
298
+ - **Next.js 16 with `src/` folder**: Place `src/proxy.ts` or `src/middleware.ts` (in `src/` folder, not root)
299
+
300
+ > **Note:** Next.js 16 renamed "middleware" to "proxy". You can use either export name, but `proxy` is recommended to avoid deprecation warnings.
301
+
302
+ ### Custom Middleware
303
+
304
+ Alternatively, you can create your own middleware:
261
305
 
262
306
  ```typescript
263
- // middleware.ts
307
+ // middleware.ts (or src/proxy.ts for Next.js 16)
264
308
  import { NextResponse } from 'next/server';
265
309
  import type { NextRequest } from 'next/server';
266
310
 
@@ -280,5 +324,5 @@ export async function middleware(request: NextRequest) {
280
324
  }
281
325
  ```
282
326
 
283
- Alternatively, you can use the `requireUserId` utility from `@solvapay/auth` in your middleware.
327
+ You can also use the `requireUserId` utility from `@solvapay/auth` in your middleware.
284
328
 
package/dist/index.d.cts CHANGED
@@ -194,10 +194,11 @@ interface AuthMiddlewareOptions {
194
194
  * 4. Returns appropriate error responses for auth failures
195
195
  *
196
196
  * @param options - Configuration options
197
- * @returns Next.js middleware function
197
+ * @returns Next.js middleware function (can be exported as `middleware` or `proxy`)
198
198
  *
199
- * @example
199
+ * @example Next.js 15
200
200
  * ```typescript
201
+ * // middleware.ts (at project root)
201
202
  * import { createAuthMiddleware } from '@solvapay/next';
202
203
  * import { SupabaseAuthAdapter } from '@solvapay/auth/supabase';
203
204
  *
@@ -215,6 +216,27 @@ interface AuthMiddlewareOptions {
215
216
  * };
216
217
  * ```
217
218
  *
219
+ * @example Next.js 16 with src/ folder
220
+ * ```typescript
221
+ * // src/proxy.ts (in src/ folder, not project root)
222
+ * import { createAuthMiddleware } from '@solvapay/next';
223
+ * import { SupabaseAuthAdapter } from '@solvapay/auth/supabase';
224
+ *
225
+ * const adapter = new SupabaseAuthAdapter({
226
+ * jwtSecret: process.env.SUPABASE_JWT_SECRET!,
227
+ * });
228
+ *
229
+ * // Use 'proxy' export for Next.js 16 (no deprecation warning)
230
+ * export const proxy = createAuthMiddleware({
231
+ * adapter,
232
+ * publicRoutes: ['/api/list-plans'],
233
+ * });
234
+ *
235
+ * export const config = {
236
+ * matcher: ['/api/:path*'],
237
+ * };
238
+ * ```
239
+ *
218
240
  * @example Custom adapter
219
241
  * ```typescript
220
242
  * import { createAuthMiddleware } from '@solvapay/next';
@@ -231,6 +253,14 @@ interface AuthMiddlewareOptions {
231
253
  * adapter: myAdapter,
232
254
  * });
233
255
  * ```
256
+ *
257
+ * **File Location Notes:**
258
+ * - **Next.js 15**: Place `middleware.ts` at project root
259
+ * - **Next.js 16 without `src/` folder**: Place `middleware.ts` or `proxy.ts` at project root
260
+ * - **Next.js 16 with `src/` folder**: Place `src/proxy.ts` or `src/middleware.ts` (in `src/` folder, not root)
261
+ *
262
+ * **Note:** Next.js 16 renamed "middleware" to "proxy". You can export the return value as either
263
+ * `middleware` or `proxy` - both work, but `proxy` is recommended to avoid deprecation warnings.
234
264
  */
235
265
  declare function createAuthMiddleware(options: AuthMiddlewareOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
236
266
  /**
@@ -261,10 +291,11 @@ interface SupabaseAuthMiddlewareOptions {
261
291
  * Uses dynamic import to avoid requiring Supabase as a dependency in @solvapay/next.
262
292
  *
263
293
  * @param options - Configuration options
264
- * @returns Next.js middleware function
294
+ * @returns Next.js middleware function (can be exported as `middleware` or `proxy`)
265
295
  *
266
- * @example
296
+ * @example Next.js 15
267
297
  * ```typescript
298
+ * // middleware.ts (at project root)
268
299
  * import { createSupabaseAuthMiddleware } from '@solvapay/next';
269
300
  *
270
301
  * export const middleware = createSupabaseAuthMiddleware({
@@ -275,6 +306,29 @@ interface SupabaseAuthMiddlewareOptions {
275
306
  * matcher: ['/api/:path*'],
276
307
  * };
277
308
  * ```
309
+ *
310
+ * @example Next.js 16 with src/ folder
311
+ * ```typescript
312
+ * // src/proxy.ts (in src/ folder, not project root)
313
+ * import { createSupabaseAuthMiddleware } from '@solvapay/next';
314
+ *
315
+ * // Use 'proxy' export for Next.js 16 (no deprecation warning)
316
+ * export const proxy = createSupabaseAuthMiddleware({
317
+ * publicRoutes: ['/api/list-plans'],
318
+ * });
319
+ *
320
+ * export const config = {
321
+ * matcher: ['/api/:path*'],
322
+ * };
323
+ * ```
324
+ *
325
+ * **File Location Notes:**
326
+ * - **Next.js 15**: Place `middleware.ts` at project root
327
+ * - **Next.js 16 without `src/` folder**: Place `middleware.ts` or `proxy.ts` at project root
328
+ * - **Next.js 16 with `src/` folder**: Place `src/proxy.ts` or `src/middleware.ts` (in `src/` folder, not root)
329
+ *
330
+ * **Note:** Next.js 16 renamed "middleware" to "proxy". You can export the return value as either
331
+ * `middleware` or `proxy` - both work, but `proxy` is recommended to avoid deprecation warnings.
278
332
  */
279
333
  declare function createSupabaseAuthMiddleware(options?: SupabaseAuthMiddlewareOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
280
334
 
package/dist/index.d.ts CHANGED
@@ -194,10 +194,11 @@ interface AuthMiddlewareOptions {
194
194
  * 4. Returns appropriate error responses for auth failures
195
195
  *
196
196
  * @param options - Configuration options
197
- * @returns Next.js middleware function
197
+ * @returns Next.js middleware function (can be exported as `middleware` or `proxy`)
198
198
  *
199
- * @example
199
+ * @example Next.js 15
200
200
  * ```typescript
201
+ * // middleware.ts (at project root)
201
202
  * import { createAuthMiddleware } from '@solvapay/next';
202
203
  * import { SupabaseAuthAdapter } from '@solvapay/auth/supabase';
203
204
  *
@@ -215,6 +216,27 @@ interface AuthMiddlewareOptions {
215
216
  * };
216
217
  * ```
217
218
  *
219
+ * @example Next.js 16 with src/ folder
220
+ * ```typescript
221
+ * // src/proxy.ts (in src/ folder, not project root)
222
+ * import { createAuthMiddleware } from '@solvapay/next';
223
+ * import { SupabaseAuthAdapter } from '@solvapay/auth/supabase';
224
+ *
225
+ * const adapter = new SupabaseAuthAdapter({
226
+ * jwtSecret: process.env.SUPABASE_JWT_SECRET!,
227
+ * });
228
+ *
229
+ * // Use 'proxy' export for Next.js 16 (no deprecation warning)
230
+ * export const proxy = createAuthMiddleware({
231
+ * adapter,
232
+ * publicRoutes: ['/api/list-plans'],
233
+ * });
234
+ *
235
+ * export const config = {
236
+ * matcher: ['/api/:path*'],
237
+ * };
238
+ * ```
239
+ *
218
240
  * @example Custom adapter
219
241
  * ```typescript
220
242
  * import { createAuthMiddleware } from '@solvapay/next';
@@ -231,6 +253,14 @@ interface AuthMiddlewareOptions {
231
253
  * adapter: myAdapter,
232
254
  * });
233
255
  * ```
256
+ *
257
+ * **File Location Notes:**
258
+ * - **Next.js 15**: Place `middleware.ts` at project root
259
+ * - **Next.js 16 without `src/` folder**: Place `middleware.ts` or `proxy.ts` at project root
260
+ * - **Next.js 16 with `src/` folder**: Place `src/proxy.ts` or `src/middleware.ts` (in `src/` folder, not root)
261
+ *
262
+ * **Note:** Next.js 16 renamed "middleware" to "proxy". You can export the return value as either
263
+ * `middleware` or `proxy` - both work, but `proxy` is recommended to avoid deprecation warnings.
234
264
  */
235
265
  declare function createAuthMiddleware(options: AuthMiddlewareOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
236
266
  /**
@@ -261,10 +291,11 @@ interface SupabaseAuthMiddlewareOptions {
261
291
  * Uses dynamic import to avoid requiring Supabase as a dependency in @solvapay/next.
262
292
  *
263
293
  * @param options - Configuration options
264
- * @returns Next.js middleware function
294
+ * @returns Next.js middleware function (can be exported as `middleware` or `proxy`)
265
295
  *
266
- * @example
296
+ * @example Next.js 15
267
297
  * ```typescript
298
+ * // middleware.ts (at project root)
268
299
  * import { createSupabaseAuthMiddleware } from '@solvapay/next';
269
300
  *
270
301
  * export const middleware = createSupabaseAuthMiddleware({
@@ -275,6 +306,29 @@ interface SupabaseAuthMiddlewareOptions {
275
306
  * matcher: ['/api/:path*'],
276
307
  * };
277
308
  * ```
309
+ *
310
+ * @example Next.js 16 with src/ folder
311
+ * ```typescript
312
+ * // src/proxy.ts (in src/ folder, not project root)
313
+ * import { createSupabaseAuthMiddleware } from '@solvapay/next';
314
+ *
315
+ * // Use 'proxy' export for Next.js 16 (no deprecation warning)
316
+ * export const proxy = createSupabaseAuthMiddleware({
317
+ * publicRoutes: ['/api/list-plans'],
318
+ * });
319
+ *
320
+ * export const config = {
321
+ * matcher: ['/api/:path*'],
322
+ * };
323
+ * ```
324
+ *
325
+ * **File Location Notes:**
326
+ * - **Next.js 15**: Place `middleware.ts` at project root
327
+ * - **Next.js 16 without `src/` folder**: Place `middleware.ts` or `proxy.ts` at project root
328
+ * - **Next.js 16 with `src/` folder**: Place `src/proxy.ts` or `src/middleware.ts` (in `src/` folder, not root)
329
+ *
330
+ * **Note:** Next.js 16 renamed "middleware" to "proxy". You can export the return value as either
331
+ * `middleware` or `proxy` - both work, but `proxy` is recommended to avoid deprecation warnings.
278
332
  */
279
333
  declare function createSupabaseAuthMiddleware(options?: SupabaseAuthMiddlewareOptions): (request: NextRequest) => Promise<NextResponse<unknown>>;
280
334
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/next",
3
- "version": "1.0.0-preview.10",
3
+ "version": "1.0.0-preview.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "sideEffects": false,
31
31
  "dependencies": {
32
- "@solvapay/auth": "1.0.0-preview.10",
33
- "@solvapay/core": "1.0.0-preview.10",
34
- "@solvapay/server": "1.0.0-preview.10"
32
+ "@solvapay/auth": "1.0.0-preview.11",
33
+ "@solvapay/core": "1.0.0-preview.11",
34
+ "@solvapay/server": "1.0.0-preview.11"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "next": ">=13.0.0"