{"id":30363176,"url":"https://github.com/rajofearth/sunx","last_synced_at":"2026-05-04T09:32:33.205Z","repository":{"id":310375700,"uuid":"1039630457","full_name":"rajofearth/sunx","owner":"rajofearth","description":"Sunx a modern, production-ready authentication template built with Next.js , Better Auth, Prisma ORM, and shadcn/ui components.","archived":false,"fork":false,"pushed_at":"2025-10-30T10:54:28.000Z","size":567,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-30T12:34:49.344Z","etag":null,"topics":["betterauth","nextjs","postgresql","prisma","prisma-orm","sqlite","template"],"latest_commit_sha":null,"homepage":"","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/rajofearth.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-17T16:45:16.000Z","updated_at":"2025-10-30T10:54:32.000Z","dependencies_parsed_at":"2025-08-17T18:27:27.439Z","dependency_job_id":"c4d6fb90-8305-49fc-9fcf-e084ff398779","html_url":"https://github.com/rajofearth/sunx","commit_stats":null,"previous_names":["rajofearth/sunx"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/rajofearth/sunx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajofearth%2Fsunx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajofearth%2Fsunx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajofearth%2Fsunx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajofearth%2Fsunx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rajofearth","download_url":"https://codeload.github.com/rajofearth/sunx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajofearth%2Fsunx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32601527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"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":["betterauth","nextjs","postgresql","prisma","prisma-orm","sqlite","template"],"created_at":"2025-08-19T18:04:53.735Z","updated_at":"2026-05-04T09:32:33.155Z","avatar_url":"https://github.com/rajofearth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sunx - Next.js Authentication Template\n\nA modern, production-ready authentication template built with Next.js 15, Better Auth, Prisma ORM, and shadcn/ui components.\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/1cde1a61-5b6d-4ef7-a912-a90f81b9dda2\" alt=\"Sign In Page\" width=\"300\" height=\"200\" style=\"border-radius: 8px; margin: 8px;\" /\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/a5d9f67a-da94-483d-bae0-a585c67c9feb\" alt=\"Sign Up Page\" width=\"300\" height=\"200\" style=\"border-radius: 8px; margin: 8px;\" /\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/731c5049-93e8-45ea-b256-bbd57319d41c\" alt=\"Dashboard\" width=\"300\" height=\"200\" style=\"border-radius: 8px; margin: 8px;\" /\u003e\n\u003c/div\u003e\n## ✨ Features\n\n- 🔐 **Complete Authentication Flow** - Sign up, sign in, password reset\n- 🎨 **Modern UI** - Beautiful dark theme with glassmorphism effects\n- ⚡ **Next.js 15** - Latest App Router with server actions\n- 🗄️ **Database Ready** - SQLite with Prisma (easy to swap to PostgreSQL)\n- 🔒 **Better Auth** - Secure authentication with session management\n- 📱 **Responsive Design** - Works perfectly on all devices\n- 🎯 **TypeScript** - Full type safety throughout\n- 🎨 **shadcn/ui** - Professional UI components\n- 🔄 **Server Actions** - Form handling with Zod validation\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Node.js 18+ \n- bun, yarn, or pnpm\n\n### 1. Clone and Install\n\n```bash\ngit clone https://github.com/rajofearth/sunx.git\ncd sunx\nbun install\n```\n\n### 2. Environment Setup\n\n```bash\ncp .env.example .env\n```\n\nUpdate `.env` with your configuration:\n```env\n# Database (SQLite by default)\nDATABASE_URL=\"file:./local.db\"\n\n# App URL (no trailing slash)\nNEXT_PUBLIC_APP_URL=\"http://localhost:3000\"\n```\n\n### 3. Database Setup\n\n```bash\n# Generate Prisma client\nbun run prisma:generate\n\n# Push schema to database\nbun run db:push\n```\n\n### 4. Start Development\n\n```bash\nbun dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) in your browser.\n\n## 🏗️ Project Structure\n\n```\nsrc/\n├── app/\n│   ├── auth/\n│   │   ├── page.tsx              # Auth page (protected from logged-in users)\n│   │   └── action.ts             # Server actions for auth\n│   ├── dashboard/\n│   │   └── page.tsx              # Protected dashboard\n│   ├── forgot-password/\n│   │   └── page.tsx              # Password reset request\n│   ├── reset-password/\n│   │   └── page.tsx              # Password reset form\n│   ├── api/auth/[...all]/\n│   │   └── route.ts              # Better Auth API routes\n│   ├── globals.css               # Global styles \u0026 Tailwind\n│   ├── layout.tsx                # Root layout\n│   └── page.tsx                  # Home page (redirects to auth/dashboard)\n├── components/\n│   ├── auth-client.tsx           # Auth UI with tabs\n│   ├── sign-in.tsx               # Sign in form\n│   ├── sign-up.tsx               # Sign up form\n│   ├── forgot-password-client.tsx # Forgot password UI\n│   ├── reset-password-client.tsx # Reset password UI\n│   └── ui/                       # shadcn/ui components\n├── lib/\n│   ├── auth.ts                   # Better Auth configuration\n│   ├── auth-client.ts            # Client-side auth utilities\n│   ├── action-helpers.ts         # Server action utilities\n│   ├── types.ts                  # Zod schemas\n│   ├── prisma.ts                 # Prisma client\n│   └── utils.ts                  # Utility functions\n└── generated/\n    └── prisma/                   # Generated Prisma client\n```\n\n## 🔧 Configuration\n\n### Better Auth Setup\n\nThe authentication is configured in `src/lib/auth.ts`:\n\n```typescript\nexport const auth = betterAuth({\n  emailAndPassword: {\n    enabled: true,\n    minPasswordLength: 8,\n    maxPasswordLength: 128,\n    async sendResetPassword({ user, url, token }, request) {\n      // TODO: Implement your email sending logic here\n      console.log(`Password reset email for ${user.email}: ${url}`);\n    },\n  },\n  database: prismaAdapter(prisma, {\n    provider: \"sqlite\",\n  }),\n  session: {\n    expiresIn: 60 * 60 * 24 * 7, // 7 days\n  },\n  plugins: [nextCookies()],\n});\n```\n\n### Database Schema\n\nThe Prisma schema includes all necessary tables for Better Auth:\n\n- **User** - User information and authentication data\n- **Session** - User sessions for authentication\n- **Account** - OAuth and credential accounts\n- **Verification** - Email verification tokens\n\n## 🎨 Customization\n\n### Styling\n\nThe template uses Tailwind CSS v4 with a custom dark theme. Customize by modifying:\n\n- `src/app/globals.css` - Global styles and CSS variables\n- Component-specific classes in the components\n- The theme uses CSS variables for easy customization\n\n### Email Provider\n\nTo enable email functionality (password reset, verification), implement the email sending functions in `src/lib/auth.ts`:\n\n```typescript\nasync sendResetPassword({ user, url, token }, request) {\n  // Example with Resend\n  await fetch('https://api.resend.com/emails', {\n    method: 'POST',\n    headers: {\n      'Authorization': `Bearer ${process.env.RESEND_API_KEY}`,\n      'Content-Type': 'application/json',\n    },\n    body: JSON.stringify({\n      from: 'noreply@yourdomain.com',\n      to: user.email,\n      subject: 'Reset your password',\n      html: `\u003ca href=\"${url}\"\u003eReset Password\u003c/a\u003e`,\n    }),\n  });\n}\n```\n\nPopular email providers:\n- [Resend](https://resend.com) - Developer-friendly email API\n- [SendGrid](https://sendgrid.com) - Enterprise email service\n- [Postmark](https://postmarkapp.com) - Transactional email\n- [AWS SES](https://aws.amazon.com/ses/) - Amazon's email service\n\n## 🚀 Deployment\n\n### Environment Variables\n\nSet these in your production environment:\n\n```env\nDATABASE_URL=\"your-production-database-url\"\nNEXT_PUBLIC_APP_URL=\"https://your-domain.com\"\n```\n\n### Database Migration\n\nFor production, consider using PostgreSQL:\n\n1. Update `prisma/schema.prisma`:\n```prisma\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n```\n\n2. Update the auth configuration:\n```typescript\ndatabase: prismaAdapter(prisma, {\n  provider: \"postgresql\",\n}),\n```\n\n3. Deploy your database and run migrations:\n```bash\nnpx prisma migrate deploy\n```\n\n### Deployment Platforms\n\nThis template works with all major deployment platforms:\n\n- **Vercel** - Recommended for Next.js apps\n- **Netlify** - Great for static sites\n- **Railway** - Easy database + app deployment\n- **Render** - Simple deployment with PostgreSQL\n- **AWS/GCP/Azure** - Enterprise deployments\n\n## 🛠️ Development\n\n### Available Scripts\n\n```bash\nbun dev          # Start development server\nbun run build        # Build for production\nbun run start        # Start production server\nbun run typecheck    # TypeScript type checking\nbun run prisma:generate  # Generate Prisma client\nbun run db:push      # Push schema to database\n```\n\n### Adding New Features\n\n1. **New Pages**: Add to `src/app/` following the existing pattern\n2. **Components**: Create in `src/components/` with proper TypeScript\n3. **Server Actions**: Use the `validatedAction` helper in `src/lib/action-helpers.ts`\n4. **Database**: Add models to `prisma/schema.prisma`\n\n## 🔒 Security Features\n\n- **Password Hashing** - Uses scrypt for secure password hashing\n- **Session Management** - Secure session handling with expiration\n- **Input Validation** - Zod schemas for all form inputs\n- **CSRF Protection** - Built-in CSRF protection with Better Auth\n- **Rate Limiting** - Configurable rate limiting for auth endpoints\n- **Type Safety** - Full TypeScript coverage\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- [Next.js](https://nextjs.org) - The React framework\n- [Better Auth](https://better-auth.com) - Authentication library\n- [Prisma](https://prisma.io) - Database toolkit\n- [shadcn/ui](https://ui.shadcn.com) - UI components\n- [Tailwind CSS](https://tailwindcss.com) - CSS framework\n\n---\n\n**Ready to build something amazing?** 🚀\n\nThis template provides a solid foundation for any Next.js application requiring authentication. Just add your business logic and deploy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajofearth%2Fsunx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frajofearth%2Fsunx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajofearth%2Fsunx/lists"}