This document provides development-related information for the NextTab project.
- Requirements
- Quick Start
- Development Mode
- Common Commands
- Project Structure
- Development Workflow
- Build and Package
- Testing
- Code Standards
- Node.js >= 18.19.1 (see
.nvmrc) - pnpm >= 9.9.0 (required)
- Git
-
Clone the Repository
git clone https://github.com/N0I0C0K/NextTab.git cd NextTab -
Install Dependencies
pnpm install
-
Start Development Mode
# Chrome development mode (with hot reload) pnpm dev # Firefox development mode pnpm dev:firefox
-
Load into Browser
Chrome/Edge:
- Open
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the
distdirectory
Firefox:
- Open
about:debugging#/runtime/this-firefox - Click "Load Temporary Add-on"
- Select
manifest.jsonin thedistdirectory
- Open
Development mode supports Hot Module Replacement (HMR), and the extension automatically reloads when files are modified.
# Chrome development mode
pnpm dev
# Firefox development mode
pnpm dev:firefoxDevelopment mode features:
- Automatic compilation and reload
- Source map support
- Fast iteration development
# Type checking
pnpm type-check
# Linting and auto-fix
pnpm lint
# Code formatting
pnpm prettier
# Production build
pnpm build # Chrome
pnpm build:firefox # Firefox
# Package as zip file (for publishing)
pnpm zip
pnpm zip:firefox
# Run E2E tests
pnpm e2e
# Update version
pnpm update-version <version>This is a pnpm + Turbo based Monorepo project:
chrome-extension/ # Core extension (manifest, background script)
pages/ # Extension UI pages
new-tab/ # Main new tab replacement page
popup/ # Extension popup
options/ # Settings page
side-panel/ # Chrome side panel
packages/ # Shared workspace packages
shared/ # Common utilities, hooks, MQTT provider
storage/ # Chrome storage abstraction layer
ui/ # Reusable UI components (based on shadcn/ui)
i18n/ # Internationalization system
hmr/ # Hot module replacement support
vite-config/ # Shared Vite configuration
- Framework: React 18
- Language: TypeScript
- Build Tools: Vite + Turbo
- Package Manager: pnpm workspaces
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- State Management: React Hooks + Chrome Storage API
- Testing: E2E testing framework
- Copy an existing page structure (e.g.,
pages/popup) - Update
package.jsonwith dependencies - Create
vite.config.mtswith entry point - Add to
chrome-extension/manifest.jsif needed - Ensure
pnpm-workspace.yamlincludes the directory
- Create storage in
packages/storage/lib/impl/usingcreateStorage() - Define TypeScript types
- Export from
packages/storage/lib/impl/index.ts - Use
useStorage()hook in React components
Example:
import { settingStorage } from '@extension/storage'
import { useStorage } from '@extension/shared'
// In component
const settings = useStorage(settingStorage)
// Update (supports deep merge)
await settingStorage.update({ wallpaperUrl: 'https://...' })Follow packages/ui/README.md for shadcn/ui components:
# Add component
pnpm dlx shadcn@latest add {component} -c ./packages/ui
# Export from packages/ui
# Add export in packages/ui/lib/components/ui/index.ts
# Use withUI() in consuming page's tailwind.config.tspnpm dev # Chrome
pnpm dev:firefox # Firefoxpnpm build # Chrome
pnpm build:firefox # FirefoxBuild output is in the dist/ directory.
# Package as zip (for store upload)
pnpm zip # Chrome
pnpm zip:firefox # FirefoxGenerated zip files are in the project root directory.
pnpm e2eTest location: tests/e2e/
Note: Current test infrastructure is limited, contributions welcome.
- Use
import type { ... }for type imports - No need to explicitly import React (globally configured)
- Use path aliases (e.g.,
@src,@root)
- Use Tailwind CSS
- Use
cn()utility for class merging (from@extension/ui) - Follow shadcn/ui component patterns
- Single quotes
- No semicolons
- 120 character width
- Trailing commas
- See
.prettierrcfor details
It's recommended to follow Conventional Commits:
feat: add new feature
fix: fix bug
docs: documentation update
style: code formatting adjustment
refactor: code refactoring
test: test related
chore: build/toolchain update
- copilot-instructions.md - Detailed architecture and development guide
- Chrome Extension Documentation
- Vite Documentation
- Turbo Documentation
- shadcn/ui Documentation
Issues and Pull Requests are welcome! Please ensure:
- Code passes
pnpm lintandpnpm type-check - Follow project code standards
- Add necessary comments and documentation
- Test your changes
Back to README.en.md