This repository is a Next.js 16 + TypeScript application built as a startups directory. It uses Sanity as a headless CMS, Auth Js for authentication, and Sentry for optional error tracking. The app includes a set of reusable UI components and utilities to demonstrate a real-world integration of these technologies.
- Next.js 16 (app router)
- React 19 (overridden in
package.json) - TypeScript
- Sanity (headless CMS) with generated TypeScript types
- Auth Js for authentication
- Sentry for error/error-trace reporting
- Tailwind CSS + styled-components for styling
- Node.js (recommend Node 20.x or the latest LTS that matches Next 16 requirements).
- npm (package.json expects npm; the project uses npm@10+ in metadata)
- (Optional) Sanity CLI for working locally with Sanity datasets:
npm i -g @sanity/cli
git clone https://github.com/NebiyouBelaineh/yc_directory_next_16
cd yc_directory
npm installCreate a .env.local file in the project root. Example variables required to run the app locally are shown below in .env.example format. Some entries are required for full functionality; others are optional.
# Auth Js
AUTH_TRUST_HOST=http://localhost:3000
AUTH_SECRET=change_me_to_a_secure_value
AUTH_GITHUB_ID=respective_oAuth_providerID/Secret
AUTH_GITHUB_SECRET=respective_oAuth_providerID/Secret
AUTH_GOOGLE_ID=respective_oAuth_providerID/Secret
AUTH_GOOGLE_SECRET=respective_oAuth_providerID/Secret
# Sanity (adjust names if your code uses different env keys)
NEXT_PUBLIC_SANITY_PROJECT_ID=your_sanity_project_id
NEXT_PUBLIC_SANITY_DATASET=production
SANITY_WRITE_TOKEN=your_sanity_token_for_writes_or_previewing
# Sentry (optional)
SENTRY_AUTH_TOKEN=your_sentry_auth_token
- If using a remote Sanity project, ensure
NEXT_PUBLIC_SANITY_PROJECT_ID, andNEXT_PUBLIC_SANITY_DATASETare set and the token is valid for any write/preview actions the app performs. - If working with a local Sanity dataset or starting a new studio, use the Sanity CLI to login and deploy/seed data as needed.
- Run the type generation step to produce TypeScript definitions used by the app:
npm run typegenThis populates sanity/extract.json and runs Sanity's type generation to keep types in sync with the schema.
Run the app (development)
npm run dev
# then open http://localhost:3000Build and run (production)
npm run build
npm startdev— starts Next.js in development mode (uses turbopack in this project)build— builds the Next.js app for production (--no-manglingflag present)start— starts the production servertypegen— extracts Sanity schema and generates TypeScript typeslint— run ESLint
app/— main Next.js app router. Pages, route handlers, and API endpoints live here. Checkapp/api/auth/[...nextauth]/route.tsfor Auth Js configuration.components/— reusable UI components.components/uicontains small primitives (avatar, button, input, textarea, skeleton).lib/— shared utility functions, actions, and validation helpers.sanity/— Sanity configuration and schema definitions.sanity/schemaTypescontains content models (startup, author, playlist, etc.).sanity/libcontains the Sanity client and helpers.public/— static assets served by Next.js.types/— TypeScript declaration augmentations (for example, Auth Js types).
Auth Js is integrated via the route under app/api/auth/[...nextauth]/route.ts. To enable provider-based login, configure provider client IDs and secrets via environment variables (for example GITHUB_ID and GITHUB_SECRET) and set NEXTAUTH_URL and NEXTAUTH_SECRET.
Sentry can be installed and configured using the sentry-cli. Sentry is optional for local development. Please refer to the following link Sentry Docs.
- Sanity type errors: run
npm run typegento regenerate types after changing schema files. - Authentication issues: verify
AUTH_TRUST_URLandAUTH_SECRET. Ensure provider client IDs/secrets and callback URLs are configured correctly in the provider dashboard. - Build or dependency mismatches: note
package.jsoncontains overrides pinning React and Next versions (React 19, Next 16). When adding dependencies, verify compatibility. - If ports conflict or the app doesn't start, ensure nothing else is using port 3000 or set
PORTenvironment variable.
package.json— scripts and dependencies (Next 16, React 19 override, Sanity, Auth Js, Sentry)next.config.ts— Next.js configurationapp/api/auth/[...nextauth]/route.ts— Auth Js route handler and provider configsanity/schemaTypes/*— Sanity content types
This project is covered under MIT License. Check LICENSE.md.