SAST Link Next is the current Next.js implementation of the SAST Link account system. It is no longer a generic starter template: the repository already contains the migrated authentication flows, account switcher, user homepage, profile editing, avatar cropping, Jest tests, and GitHub Actions workflows.
- Provides tourist-side flows for login, registration, password reset, and OAuth callbacks.
- Provides user-side flows for homepage overview, profile side panels, profile editing, avatar upload/cropping, and safety settings entry.
- Uses web runtime (
pnpm dev) and static-export build (pnpm build) as the main delivery model. - Uses the existing SAST Link backend through
NEXT_PUBLIC_API_BASE_URL, with optional MSW mocking for local development.
- Next.js 16 App Router
- React 19
- TypeScript (strict mode)
- Tailwind CSS v4
- shadcn/ui + Radix primitives
- Zustand for client-side state
- SWR for client-side data fetching defaults
- Axios for API access
- React Hook Form + validation helpers
- Jest 30 + Testing Library + MSW
/account switcher / quick-login entry/logintwo-step password login/registerfour-step registration flow/resetfour-step password reset flow/callback/feishuFeishu OAuth callback/callback/githubGitHub OAuth callback
/homehomepage overview with profile summary, quick actions, and app links/home/editprofile editing and avatar cropping/upload/home/edit/safetysafety settings page
app/(tourist)/layout.tsxwraps unauthenticated pages with the shared background layout.app/(user)/layout.tsxredirects to/loginwhen no token is present.app/(user)/home/layout.tsxfetches profile state and composes the top bar plus side panels.
sast-link-next/
├── app/ # App Router routes, layouts, providers, page tests
│ ├── page.tsx # Account switcher / root entry
│ ├── providers.tsx # SWR config + optional MSW bootstrap + global message panel
│ ├── (tourist)/ # Login / register / reset / OAuth callback flows
│ └── (user)/ # Authenticated homepage and edit flows
├── components/
│ ├── account/ # Account switcher UI
│ ├── animation/ # Page transition helpers
│ ├── auth/ # Auth-related reusable inputs/widgets
│ ├── feedback/ # Global message panel
│ ├── icons/ # Brand/logo icons
│ ├── layout/ # Shared backgrounds, footer, top bar
│ ├── navigation/ # Back button
│ ├── profile/ # Profile bind items
│ └── ui/ # shadcn/ui-style primitives
├── hooks/
│ └── use-fetch-profile.ts # Loads and syncs authenticated profile data
├── lib/
│ ├── api/ # Axios client and auth/user/oauth API wrappers
│ ├── constants/ # Shared constants
│ ├── validations/ # Form validation rules
│ ├── token.ts # Token persistence helpers
│ └── message.ts # Global toast/message facade
├── mocks/ # MSW setup used when NEXT_PUBLIC_API_MOCKING=true
├── public/ # Static assets and generated MSW worker
├── store/ # Zustand stores
├── tests/ # Shared test helpers / higher-level tests
├── .github/workflows/ # CI/CD, test, deploy, and release workflows
├── TESTING.md # Test strategy and commands
├── CI_CD.md # GitHub Actions workflow guide
└── CONTRIBUTING.md # Contribution workflow
store/use-auth-store.ts: logged-in user identity, login ticket, redirect target, logout behavior.store/use-user-list-store.ts: remembered accounts for root-page switching.store/use-user-profile-store.ts: editable profile state used on homepage and edit pages.store/use-panel-store.ts: homepage side-panel open state.
lib/api/client.ts: shared Axios instance, readsNEXT_PUBLIC_API_BASE_URL, injectsTokenheader automatically.lib/api/auth.ts: verify account, send mail, captcha verification, register, reset password, OAuth callbacks.lib/api/user.ts: login, logout, profile retrieval/update, avatar upload, bind status.
next.config.tsusesoutput: "export"sopnpm buildemitsout/.
- Node.js 20 or newer
- pnpm 10 is what CI uses; local pnpm 8+ can work, but matching CI is recommended
pnpm installCreate a local environment file if you need to point at a backend or enable mocks:
NEXT_PUBLIC_API_BASE_URL=http://118.25.23.101:8081/api/v1
NEXT_PUBLIC_API_MOCKING=falseNotes:
.env*files are ignored by git.- Set
NEXT_PUBLIC_API_MOCKING=trueto bootstrap MSW fromapp/providers.tsx. - The checked-in
.env.exampledocuments the two supported public env vars today.
| Command | What it does |
|---|---|
pnpm dev |
Start the Next.js web app on port 3000 |
pnpm build |
Create the static export in out/ |
pnpm start |
Start the Next.js production server |
pnpm lint |
Run ESLint |
pnpm test |
Run the Jest suite |
pnpm test:watch |
Run Jest in watch mode |
pnpm test:coverage |
Run Jest with coverage output |
pnpm devOpen http://localhost:3000 and exercise:
/for stored-account switching/login,/register,/reset/homeafter authenticating or mocking data
pnpm lint
pnpm test
pnpm buildThe repository already has an active Jest setup. Tests live next to source files and cover app/, components/, hooks/, lib/, and store/.
Examples in the current tree:
app/page.test.tsxapp/(tourist)/login/page.test.tsxapp/(user)/home/homepage.test.tsxcomponents/layout/top-bar.test.tsxhooks/use-fetch-profile.test.tsxlib/api/auth.test.tsstore/use-auth-store.test.ts
See TESTING.md for the full testing guide.
GitHub Actions are already configured:
ci.ymlorchestrates quality and test workflows on pushes/PRs tomasteranddevelop.quality.ymlruns lint,tsc --noEmit,pnpm audit, andpnpm outdated.test.ymlrunspnpm test:coverage, uploads reports/artifacts, and runspnpm build.deploy.ymlexists but is disabled by default.release.ymlcreates a draft GitHub release when av*tag is pushed.
See CI_CD.md for exact trigger and secret details.
- The npm package name in
package.jsonis stillreact-quick-starter, but the implemented product and runtime metadata are already SAST Link oriented in the app UI and metadata. - The app metadata currently comes from
app/layout.tsxand is set totitle: "SAST Link"anddescription: "OAuth of SAST".