Skip to content

Adapt latest nextjs & react#23

Merged
ByteKatana merged 56 commits into
mainfrom
adapt-latest-nextjs
Feb 17, 2026
Merged

Adapt latest nextjs & react#23
ByteKatana merged 56 commits into
mainfrom
adapt-latest-nextjs

Conversation

@ByteKatana

Copy link
Copy Markdown
Owner

This PR focuses on (#16 ) upgrading the core technology stack and migrating the dashboard from the Pages Router to the App Router. It also includes a significant upgrade of authentication logic from next-auth v4 to v5 (Auth.js) and the introduction of Server Actions to replace legacy API calls.

🔄 Key Changes

🏗 Framework & Library Upgrades

  • Next.js & React: Upgraded to Next.js 16 and React 19.
  • TypeScript: Updated to v5.3.3.
  • Dependencies: Updated various packages including mongodb, bcryptjs, and testing libraries to ensure compatibility with React 19.
  • Configuration: Updated tsconfig.json with stricter type checks and modern JSX transforms (react-jsx). Added import aliases for cleaner path management.

🗺 App Router Migration

  • Migrated the dashboard and its sub-pages (entries, entry-types, permission-groups, users, settings) from the pages directory to the app directory.
  • Implemented layout.tsx and page.tsx structure for the dashboard.
  • Updated metadata handling using the new generateMetadata and static metadata exports.

🔐 Authentication (Auth.js v5)

  • Migrated next-auth v4 to v5 (Auth.js).
  • Removed deprecated Pages Router Auth APIs and the old login page.
  • Implemented new authentication logic in auth.ts and App Router-compatible route handlers (app/api/auth/[...nextauth]/route.ts).
  • Added a new LoginForm component

⚡ Server Actions & Data Fetching

  • Replaced inline axios API calls in components with reusable Server Actions located in lib/actions.
  • Implemented actions for:
    • Entries: Create, update, delete, and fetch by ID/slug.
    • Entry Types: Management of dynamic schemas.
    • Permission Groups: Permissions and access control management.
    • Users: User administration.
    • Settings: API key generation and dashboard configuration.
  • Standardized action responses using new ActionResponse, SuccessResponse, and ErrorResponse types.

🧪 Testing & QA

  • Cucumber BDD: Converted Auth.js v5 tests to Gherkin/Cucumber format for better E2E coverage.
  • Integration Tests: Added new integration tests for route handlers and authentication config.

🧹 Refactoring & Cleanup

  • Middleware to Proxy: Migrated from middleware.ts to a custom proxy.ts implementation.
  • Code Cleanup: Removed unused files, deprecated Auth APIs, and debug logs.
  • Type Safety: Improved interface definitions for form fields and API responses.

Signed-off-by: ByteKatana <19264901+ByteKatana@users.noreply.github.com>
Signed-off-by: ByteKatana <19264901+ByteKatana@users.noreply.github.com>
Signed-off-by: ByteKatana <19264901+ByteKatana@users.noreply.github.com>
Signed-off-by: ByteKatana <19264901+ByteKatana@users.noreply.github.com>
- Added `getSettings` action to fetch permission groups, namespaces, and API keys.
- Added `generateApiKeyAction` to handle API key generation.
- Added `removeApiKeyAction` to handle API key removal.
- Introduced server action `updatePermissionsAction` for updating permission groups via API.
- Moved `entry-types` page component to `components/pages/entry-types`.
- Updated routing to use the new app router
- Added checks for `permGroupData` and its `privileges` before updating.
- Enhanced error handling for cases where permission group updates fail.
- Ensured namespace validation when updating entry types.
- Create new auth.ts configuration with Auth.js v5 patterns
- Migrate login to App Router (app/login/page.tsx + LoginForm.tsx)
- Add App Router API handler (app/api/auth/[...nextauth]/route.ts)
- Implement middleware for /dashboard/* route protection
- Create server-side session helpers (lib/auth/get-session.ts)
- Add sign-out server actions with multiple variants
- Update type definitions for Auth.js v5
- Preserve custom session fields (permission_group)
- Maintain JWT strategy with MongoDB Credentials provider
- Add comprehensive test suite (60+ test cases):
  - Unit tests for auth configuration
  - Integration tests for API routes
  - E2E tests for complete auth flow
- Update Cypress tests for new cookie name (authjs.session-token)
- Clean up deprecated NextResponse imports
- Remove dead getServerSideProps from client components
- Fix Tailwind config to include /app directory
- Enable TypeScript strict mode
- Add complete migration plan and checklist

Breaking Changes:
- Session cookie renamed: next-auth.session-token → authjs.session-token
- All users will be logged out on deployment
- next-auth package updated from v4.20.1 to v5.0.0-beta.30
- Add Auth.js v5 middleware proxy for protecting dashboard and API routes
- Enforce authentication and group-based access control for sensitive paths
- Redirect unauthorized users to login or dashboard pages
@ByteKatana ByteKatana linked an issue Feb 17, 2026 that may be closed by this pull request
@ByteKatana ByteKatana self-assigned this Feb 17, 2026
@ByteKatana ByteKatana linked an issue Feb 17, 2026 that may be closed by this pull request
6 tasks
@ByteKatana ByteKatana merged commit 8a2d079 into main Feb 17, 2026
1 of 2 checks passed
@ByteKatana ByteKatana linked an issue Feb 17, 2026 that may be closed by this pull request
6 tasks
@ByteKatana ByteKatana deleted the adapt-latest-nextjs branch February 17, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upgrade next-auth to v5 adapt users to new app router adapt entries to new app router

1 participant