{"id":51635811,"url":"https://github.com/onlineeric/eric-demo-nextjs","last_synced_at":"2026-07-13T14:04:28.653Z","repository":{"id":310305677,"uuid":"1039380051","full_name":"onlineeric/eric-demo-nextjs","owner":"onlineeric","description":"My demo next.js app","archived":false,"fork":false,"pushed_at":"2025-08-17T06:47:26.000Z","size":139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-17T08:27:15.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onlineeric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-17T05:06:30.000Z","updated_at":"2025-08-17T06:47:30.000Z","dependencies_parsed_at":"2025-08-17T08:38:08.669Z","dependency_job_id":null,"html_url":"https://github.com/onlineeric/eric-demo-nextjs","commit_stats":null,"previous_names":["onlineeric/eric-demo-nextjs"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/onlineeric/eric-demo-nextjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlineeric%2Feric-demo-nextjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlineeric%2Feric-demo-nextjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlineeric%2Feric-demo-nextjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlineeric%2Feric-demo-nextjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onlineeric","download_url":"https://codeload.github.com/onlineeric/eric-demo-nextjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlineeric%2Feric-demo-nextjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35424577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-13T14:04:27.777Z","updated_at":"2026-07-13T14:04:28.645Z","avatar_url":"https://github.com/onlineeric.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next.js Exercise (HeroUI + Tailwind)\n\nLearn Next.js by building and running this app. Each page demonstrates one concept:\nCSR, SSR, SSG, ISR, client-side navigation, RSC, Route Handlers (API), Server Actions,\nDynamic Routes, Error Handling, Middleware, Image Optimization, and Environment Variables.\n\n## Setup\n\nPrerequisite: Node.js 18+ (20+ recommended)\n\n1. Create `.env.local` (optional - for environment variables demo) with:\n\n```\nSECRET_KEY=super-secret\nNEXT_PUBLIC_BASE_URL=http://localhost:3000\n```\n2. `npm install`\n3. `npm run dev`\n4. Open `http://localhost:3000`\n\n## Scripts\n\n- `npm run dev` - Start development server\n- `npm run build \u0026\u0026 npm run start` - Build and run production\n- `npm run lint` - Check code quality\n- `npm run typecheck` - TypeScript type checking\n\n## What to Try\nThis app is for developers familiar with React SPA who want to learn Next.js.\n\n### Core Rendering Patterns\n- `/csr` - Client-side data fetching (classic SPA behavior)\n- `/ssr` - Server-side rendering (fresh data on each request)\n- `/ssg` - Static site generation (built at build time)\n- `/isr` - Incremental static regeneration (revalidates periodically)\n\n### Navigation \u0026 Routing\n- `/navigation` - Client-side navigation without full reload\n- `/dynamic` - Dynamic route segments with [id] and [...slug] patterns\n- `/dynamic/123` - Single dynamic parameter example\n- `/dynamic/products/electronics/phones` - Catch-all route example\n\n### Server Components \u0026 Data Fetching\n- `/rsc` - Server vs Client Components with parallel vs sequential data fetching\n- `/api-demo` - Route Handlers (built-in API endpoints)\n- `/actions` - Server Actions (form handling without separate API)\n\n### Advanced Features\n- `/error-demo` - Error handling with error.tsx and not-found.tsx\n- `/middleware-demo` - Middleware for request/response modification\n- `/images` - Image optimization with next/image component\n- `/env-vars` - Environment variables (server-only vs public)\n- `/dark-mode` - Dark mode and theming (HeroUI + next-themes)\n- `/ui-components` - UI components demo built with HeroUI\n\n### Error Testing\n- `/error-demo/server-error` - Trigger server error (demonstrates error.tsx)\n- `/error-demo/client-error` - Trigger client error\n- `/error-demo/nonexistent-page` - Test 404 handling (not-found.tsx)\n\n### Middleware Examples\n- `/old-path` - Redirects to middleware demo page\n- `/protected/secret` - Requires auth cookie (redirects if missing)\n\nNote: To access `/protected/secret`, set a cookie in your browser console:\n`document.cookie = \"auth-token=demo; path=/\";`\n\n## Key Learning Points\n\n### 1. Rendering Patterns\nCompare how the same content is loaded differently:\n- **CSR**: Loading state → API call → content (in browser)\n- **SSR**: Immediate content (rendered on server per request)\n- **SSG**: Immediate content (pre-built at build time)\n- **ISR**: Immediate content (revalidates in background)\n\n### 2. Dynamic Routes\n- `[id]` - Single dynamic segment (e.g., `/dynamic/123`)\n- `[...slug]` - Catch-all routes (e.g., `/dynamic/a/b/c`)\n- Access params via `params` prop in page components\n\n### 3. Error Handling\n- `error.tsx` - Catches runtime errors in route segments\n- `not-found.tsx` - Custom 404 pages per route\n- `global-error.tsx` - Root-level error boundary\n\n### 4. Data Fetching Best Practices\n- Use Promise.all() for parallel data fetching\n- Avoid waterfall patterns (sequential awaits)\n- Server Components for data, Client Components for interactivity\n\n### 5. Middleware\n- Runs before every request on the Edge Runtime\n- Perfect for auth, redirects, header modification\n- Configure paths with `matcher` in config\n\n### 6. Image Optimization\n- `next/image` provides automatic optimization\n- Lazy loading, responsive images, WebP/AVIF formats\n- Requires width/height or fill prop for layout stability\n\n### 7. Environment Variables\n- Server-only: `VARIABLE_NAME` (secure, not in client bundle)\n- Public: `NEXT_PUBLIC_VARIABLE_NAME` (accessible everywhere)\n- Loaded at build time from .env files\n\n## File Structure Highlights\n\n```\nsrc/\n├── middleware.ts                     # Request/response middleware\n├── app/\n│   ├── layout.tsx                   # Root layout\n│   ├── global-error.tsx             # Global error boundary\n│   ├── providers.tsx                # Providers (theme, etc.)\n│   ├── api/\n│   │   └── time/route.ts           # API route handler\n│   ├── protected/\n│   │   └── secret/page.tsx         # Protected page (middleware-gated)\n│   └── (dashboard)/                # Route group (doesn't affect URL)\n│       ├── layout.tsx              # Shared dashboard layout\n│       ├── page.tsx                # Home page\n│       ├── actions/\n│       ├── api-demo/\n│       ├── csr/\n│       ├── dark-mode/\n│       ├── dynamic/\n│       ├── env-vars/\n│       ├── error-demo/\n│       ├── images/\n│       ├── isr/\n│       ├── navigation/\n│       ├── rsc/\n│       ├── ssg/\n│       ├── ssr/\n│       └── ui-components/\n└── components/\n    ├── Topbar.tsx                  # Navigation header\n    └── Sidebar.tsx                 # Navigation sidebar\n```\n\n## Development Tips\n\n1. **Use the Network tab** to observe differences between rendering patterns\n2. **Check View Source** to see server-rendered HTML vs client-rendered content\n3. **Monitor console logs** for middleware and data fetching patterns\n4. **Test error scenarios** to understand error boundaries\n5. **Inspect headers** to see middleware modifications\n\n## Notes\n\n- This is a teaching repo: minimal, commented, and safe to copy into real projects\n- All concepts use real API calls to demonstrate authentic behavior\n- Error pages only show in production; development shows error overlay\n- Middleware logs appear in the terminal running the dev server\n\n## Next Steps\n\nAfter exploring this app, try:\n1. Adding authentication with NextAuth.js\n2. Implementing a database with Prisma\n3. Adding real-time features with WebSockets\n4. Deploying to Vercel or another platform\n5. Adding tests with Jest and React Testing Library","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlineeric%2Feric-demo-nextjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonlineeric%2Feric-demo-nextjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlineeric%2Feric-demo-nextjs/lists"}