@tidecloak/create-nextjs 0.13.11 → 0.13.14

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
@@ -197,16 +197,9 @@ function Dashboard() {
197
197
  * `<Unauthenticated>`: renders children only when `authenticated === false`
198
198
 
199
199
 
200
- ### Edge Middleware with TideCloak
200
+ ### Route Protection with TideCloak
201
201
 
202
- TideCloak’s Edge middleware works seamlessly with both the **Pages Router** and the **App Router** in Next.js:
203
-
204
- * **Pages Router**: Place your `middleware.ts` file at the project root alongside `pages/`. The exported middleware will apply to both page and API routes.
205
- * **App Router**: Put `middleware.ts` at the project root (or inside `src/`). It integrates with `/app` routes and layouts, protecting both server components and route handlers.
206
-
207
- #### Installation
208
-
209
- No additional install-middleware is included in `@tidecloak/nextjs`.
202
+ TideCloak provides server-side route protection for both the **Pages Router** and the **App Router** in Next.js.
210
203
 
211
204
  #### Options
212
205
 
@@ -217,14 +210,36 @@ No additional install-middleware is included in `@tidecloak/nextjs`.
217
210
  * **`onFailure`**<br>`(ctx: { token: string | null }, req: NextRequest) => NextResponse | void`<br>Hook when auth or role check fails; return a `NextResponse` to override.
218
211
  * **`onError`**<br>`(err: any, req: NextRequest) => NextResponse`<br>Hook for unexpected errors in middleware logic.
219
212
 
220
- #### Example Usage
213
+ #### Next.js 16+ (proxy.ts)
214
+
215
+ Create `proxy.ts` at your project root. Proxy runs on Node.js runtime.
216
+
217
+ ```ts
218
+ import { NextResponse } from 'next/server';
219
+ import tidecloakConfig from './tidecloakAdapter.json';
220
+ import { createTideCloakProxy } from '@tidecloak/nextjs/server';
221
+
222
+ export const proxy = createTideCloakProxy({
223
+ config: tidecloakConfig,
224
+ protectedRoutes: {
225
+ '/admin/*': ['admin'],
226
+ '/api/private/*': ['user'],
227
+ },
228
+ onFailure: ({ token }, req) => NextResponse.redirect(new URL('/login', req.url)),
229
+ onError: (err, req) => NextResponse.rewrite(new URL('/error', req.url)),
230
+ });
231
+ ```
232
+
233
+ > **Important:** Do NOT add `export const config` to proxy.ts - it's not supported and will cause errors. Proxy files always run on Node.js runtime and don't need a matcher config.
234
+
235
+ #### Next.js 13-15 (middleware.ts)
221
236
 
222
- Place the following `middleware.ts` at your project root (works for both Pages and App routers) to protect both page routes and API handlers:
237
+ Create `middleware.ts` at your project root. Middleware runs on Edge runtime.
223
238
 
224
239
  ```ts
225
240
  import { NextResponse } from 'next/server';
226
241
  import tidecloakConfig from './tidecloakAdapter.json';
227
- import { createTideCloakMiddleware } from '@tidecloak/nextjs/server/tidecloakMiddleware';
242
+ import { createTideCloakMiddleware } from '@tidecloak/nextjs/server';
228
243
 
229
244
  export default createTideCloakMiddleware({
230
245
  config: tidecloakConfig,
@@ -241,7 +256,6 @@ export const config = {
241
256
  '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
242
257
  '/api/(.*)',
243
258
  ],
244
- runtime: 'edge',
245
259
  };
246
260
  ```
247
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidecloak/create-nextjs",
3
- "version": "0.13.11",
3
+ "version": "0.13.14",
4
4
  "type": "module",
5
5
  "description": "Scaffold a TideCloak-ready Next.js app with optional IAM setup and working auth - start building instantly with a live example",
6
6
  "bin": {
@@ -9,9 +9,9 @@
9
9
  "init": "bash init/tcinit.sh"
10
10
  },
11
11
  "dependencies": {
12
- "next": "14.x",
13
- "react": "18.x",
14
- "react-dom": "18.x",
15
- "@tidecloak/nextjs": "^0.13.11"
12
+ "next": "16.x",
13
+ "react": "19.x",
14
+ "react-dom": "19.x",
15
+ "@tidecloak/nextjs": "^0.13.14"
16
16
  }
17
17
  }
@@ -9,9 +9,9 @@
9
9
  "init": "bash init/tcinit.sh"
10
10
  },
11
11
  "dependencies": {
12
- "next": "14.x",
13
- "react": "18.x",
14
- "react-dom": "18.x",
15
- "@tidecloak/nextjs": "^0.12.15"
12
+ "next": "16.x",
13
+ "react": "19.x",
14
+ "react-dom": "19.x",
15
+ "@tidecloak/nextjs": "^0.13.11"
16
16
  }
17
17
  }
@@ -9,10 +9,10 @@
9
9
  "init": "bash init/tcinit.sh"
10
10
  },
11
11
  "dependencies": {
12
- "next": "14.x",
13
- "react": "18.x",
14
- "react-dom": "18.x",
15
- "@tidecloak/nextjs": "^0.13.11"
12
+ "next": "16.x",
13
+ "react": "19.x",
14
+ "react-dom": "19.x",
15
+ "@tidecloak/nextjs": "^0.13.14"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "24.0.13",
@@ -9,10 +9,10 @@
9
9
  "init": "bash init/tcinit.sh"
10
10
  },
11
11
  "dependencies": {
12
- "next": "14.x",
13
- "react": "18.x",
14
- "react-dom": "18.x",
15
- "@tidecloak/nextjs": "^0.12.15"
12
+ "next": "16.x",
13
+ "react": "19.x",
14
+ "react-dom": "19.x",
15
+ "@tidecloak/nextjs": "^0.13.11"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "24.0.13",