A server-side rendered Next.js application that displays a random cat fact on every page load.
- Server-side rendering (SSR) for optimal performance
- Fetches data from the Cat Facts API on every page load
- Beautiful gradient UI with responsive design
- Random cat fact selection from the API response
- One-click refresh button to get new facts
Run the development server:
npm run devOpen http://localhost:3000 in your browser to see the application.
npm run build
npm startThe application uses Next.js App Router with server components. The page.tsx file:
- Fetches data from
https://catfact.ninja/facton every request - Uses
cache: 'no-store'to ensure fresh data on every page load - Returns a random cat fact from the API
- Renders the fact server-side before sending HTML to the client
This app uses the catfact.ninja API which returns a random cat fact on each request.
- Next.js 15
- React 19
- TypeScript
- Server-Side Rendering
- Sentry (Error Monitoring & Performance Tracking)
This project is configured with Sentry for error monitoring and performance tracking.
-
Create a Sentry account at sentry.io if you don't have one
-
Create a new Sentry project for Next.js
-
Set up environment variables:
Copy the example files and fill in your Sentry credentials:
cp .env.local.example .env.local cp .env.sentry-build-plugin.example .env.sentry-build-plugin
Update
.env.localwith your DSN:NEXT_PUBLIC_SENTRY_DSN=https://your-dsn@your-instance.ingest.sentry.io/your-project-id
Update
.env.sentry-build-pluginwith your auth token:SENTRY_AUTH_TOKEN=your-auth-token-here SENTRY_ORG=your-org-slug SENTRY_PROJECT=your-project-slug
-
Get your credentials from Sentry:
- DSN: Go to Settings → Projects → [Your Project] → Client Keys (DSN)
- Auth Token: Go to Settings → Account → API → Auth Tokens → Create New Token
- Organization Slug: Found in your Sentry URL (sentry.io/organizations/YOUR-ORG-SLUG/)
- Project Slug: Found in your project settings
After configuration, test that Sentry is working by triggering an error in your application.
- Error Tracking: Automatically captures unhandled errors and exceptions
- Performance Monitoring: Tracks application performance and slow transactions
- Session Replay: Records user sessions (configurable sample rate)
- Source Maps: Automatically uploads source maps during build for better stack traces
- Breadcrumbs: Tracks user actions leading up to errors
sentry.client.config.ts- Client-side Sentry configurationsentry.server.config.ts- Server-side Sentry configurationsentry.edge.config.ts- Edge runtime Sentry configurationinstrumentation.ts- Server instrumentation hooknext.config.ts- Next.js config with Sentry webpack plugin