Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/route-groups-auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Authenticated Route Groups Architecture

## Overview
Previously, pages requiring user authentication (such as `/account`, `/change-password`, `/verify-email`) manually rendered `<ReduxGateWrapper>` and `<ProtectedPageWrapper>` within their page components or local layouts.

## New Route Group Pattern
Next.js route groups `(authenticated)` allow sharing a root authenticated layout without altering the URL path structure:
- `src/app/[locale]/(authenticated)/layout.tsx`: Gates all subroutes with `ReduxGateWrapper` and `ProtectedPageWrapper`.
- Individual pages under `(authenticated)` automatically inherit authorization and Redux rehydration guards without redundant boilerplate.
- Simplifies testing and guarantees uniform authentication checks across all protected subroutes.
19 changes: 19 additions & 0 deletions src/app/[locale]/(authenticated)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import { ReduxGateWrapper } from '../../components/ReduxGateWrapper';
import { ProtectedPageWrapper } from '../../components/ProtectedPageWrapper';

/**
* Route group layout providing auth guarding and Redux hydration
* for all authenticated pages (e.g. account, change-password).
*/
export default function AuthenticatedLayout({
children,
}: {
children: React.ReactNode;
}): React.ReactElement {
return (
<ReduxGateWrapper>
<ProtectedPageWrapper>{children}</ProtectedPageWrapper>
</ReduxGateWrapper>
);
}