UNPKG

create-onetech-app

Version:

CLI to quickly set up React projects with popular templates and tools.

233 lines (176 loc) • 7.67 kB
# OneTech Next.js + Firebase Template A production-ready [Next.js](https://nextjs.org) template with Firebase integration, TypeScript, and Tailwind CSS from the OneTech open-source collection. ## šŸš€ Quick Start Create a new project using this template: ```bash npx create-onetech-app my-app --base=nextjs --lang=ts --template=app-tw-firebase ``` ## ✨ What's Included This template provides everything you need to build modern web applications: - ⚔ **Next.js 15** with App Router and Server Components - šŸ”„ **Firebase Integration** - Authentication, Firestore, and Storage ready - šŸŽØ **Tailwind CSS** with dark mode support - šŸ“± **Responsive Design** optimized for all devices - šŸŒ™ **Theme System** - Light, Dark, and System preference - šŸ”’ **TypeScript** for enhanced developer experience - šŸ“¦ **Production Ready** with optimized build configuration - 🧩 **Component Architecture** for scalable development ## šŸ›  Tech Stack - **Framework**: Next.js 15 (App Router) - **Language**: TypeScript - **Styling**: Tailwind CSS - **Backend**: Firebase (Auth, Firestore, Storage) - **State Management**: React Context API - **Icons**: Optimized SVG components ## šŸ“‹ Prerequisites - Node.js 18 or later - A Firebase project (free tier available) ## šŸ”§ Setup & Configuration After creating your project with `create-onetech-app`, follow these steps: ### 1. Install Dependencies ```bash cd my-app npm install ``` ### 2. Firebase Setup 1. Create a Firebase project at [Firebase Console](https://console.firebase.google.com/) 2. Enable Authentication and Firestore Database 3. Get your Firebase config from Project Settings → General → Your apps 4. Create a `.env.local` file in your project root: ```env NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id ``` ### 3. Start Development Server ```bash npm run dev ``` Open [http://localhost:3000](http://localhost:3000) to see your application running. ## šŸ“ Project Structure ``` ā”œā”€ā”€ public/ # Static assets │ ā”œā”€ā”€ firebase.svg # Firebase logo │ ā”œā”€ā”€ next.svg # Next.js logo │ ā”œā”€ā”€ onetech.svg # OneTech logo ā”œā”€ā”€ src/ │ ā”œā”€ā”€ app/ # Next.js App Router │ │ ā”œā”€ā”€ favicon.ico # App favicon │ │ ā”œā”€ā”€ globals.css # Global styles │ │ ā”œā”€ā”€ layout.tsx # Root layout │ │ └── page.tsx # Home page │ ā”œā”€ā”€ components/ # Reusable UI components │ │ ā”œā”€ā”€ Navbar.tsx # Navigation component │ │ └── ThemeToggler.tsx # Dark/light mode toggle │ ā”œā”€ā”€ context/ # React Context providers │ │ ā”œā”€ā”€ firebase/ # Firebase context modules │ │ └── theme/ # Theme context modules │ ā”œā”€ā”€ hooks/ # Custom React hooks │ │ ā”œā”€ā”€ firebase/ # Firebase-related hooks │ │ └── theme/ # Theme-related hooks │ ā”œā”€ā”€ lib/ # Utility libraries │ │ └── firebase.tsx # Firebase configuration │ └── types/ # TypeScript type definitions │ └── ThemeMode.ts # Theme type definitions ā”œā”€ā”€ .env.local # Environment variables (create this) ā”œā”€ā”€ eslint.config.mjs # ESLint configuration ā”œā”€ā”€ next.config.ts # Next.js configuration ā”œā”€ā”€ package.json # Dependencies and scripts ā”œā”€ā”€ postcss.config.mjs # PostCSS configuration ā”œā”€ā”€ README.md # Project documentation └── tsconfig.json # TypeScript configuration ``` ## šŸ”„ Firebase Integration This template comes pre-configured with Firebase services: ### Authentication - Email/Password authentication - Google Sign-In (configurable) - Protected routes and user session management - Authentication state persistence ### Firestore Database - Real-time database operations - Type-safe document operations - Collection and subcollection support - Optimistic UI updates ### Storage (Optional) - File upload capabilities - Image optimization - Secure file access rules ### Configuration All Firebase services are configured in `src/lib/firebase.tsx`. The template uses environment variables for secure configuration management. ## šŸŽØ Theme System Built-in theme support with three modes: - **šŸŒž Light Mode**: Clean, bright interface - **šŸŒ™ Dark Mode**: Easy on the eyes for night coding - **āš™ļø System Mode**: Automatically follows OS preference - **šŸ’¾ Persistent**: Saves user preference in localStorage ### Usage Example ```tsx import { useTheme } from '@/context/ThemeContext'; export default function ThemeButton() { const { theme, toggleTheme } = useTheme(); return ( <button onClick={() => toggleTheme(theme === 'dark' ? 'light' : 'dark')} className="p-2 rounded-lg bg-gray-200 dark:bg-gray-800" > {theme === 'dark' ? 'šŸŒž' : 'šŸŒ™'} </button> ); } ``` ## šŸš€ Available Scripts - `npm run dev` - Start development server - `npm run build` - Build for production - `npm run start` - Start production server - `npm run lint` - Run ESLint - `npm run type-check` - Run TypeScript compiler check ## Deployment ### Vercel (Recommended) 1. Push your code to GitHub 2. Connect your repository to [Vercel](https://vercel.com) 3. Add your environment variables in Vercel dashboard 4. Deploy automatically on every push ### Firebase Hosting 1. Install Firebase CLI: `npm install -g firebase-tools` 2. Login: `firebase login` 3. Initialize: `firebase init hosting` 4. Build: `npm run build` 5. Deploy: `firebase deploy` ## Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add some amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request 5. Open a Pull Request ## Learn More ### Next.js Resources - [Next.js Documentation](https://nextjs.org/docs) - Learn about Next.js features and API - [Learn Next.js](https://nextjs.org/learn) - Interactive Next.js tutorial - [Next.js GitHub repository](https://github.com/vercel/next.js) ### Firebase Resources - [Firebase Documentation](https://firebase.google.com/docs) - Complete Firebase guides - [Firebase Console](https://console.firebase.google.com/) - Manage your Firebase projects - [Firebase CLI Reference](https://firebase.google.com/docs/cli) ### Additional Resources - [Tailwind CSS Documentation](https://tailwindcss.com/docs) - [TypeScript Documentation](https://www.typescriptlang.org/docs/) - [React Documentation](https://react.dev/) ## šŸ™ Acknowledgments This template is part of the OneTech open-source initiative, built with ā¤ļø for the developer community. ### Core Technologies - [Next.js](https://nextjs.org) - The React Framework for Production - [Firebase](https://firebase.google.com) - Google's app development platform - [Tailwind CSS](https://tailwindcss.com) - Utility-first CSS framework - [TypeScript](https://typescriptlang.org) - JavaScript with type safety ## šŸ“„ License This project is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details. --- <div align="center"> <strong>Built with ā¤ļø by the OneTech Team</strong><br> <sub>Star ⭐ this repo if you find it helpful!</sub> </div>