0.1.7 • Published 8 months ago
create-p2js-app v0.1.7
P2.js - High Performance React Framework
P2.js is a modern React framework designed for maximum performance and developer productivity.
Key Features
🚀 Performance Optimizations
- Streaming SSR: Faster initial page loads with streaming server-side rendering
- Automatic Chunking: Smart code splitting and lazy loading
- SWC Compilation: Ultra-fast TypeScript/JavaScript compilation
- Optimized Caching: Intelligent data and asset caching strategies
- Selective Hydration: Prioritized client-side hydration
🛠 Developer Experience
- TypeScript First: Full TypeScript support with strict type checking
- Zero Config: Works out of the box with sensible defaults
- Hot Module Replacement: Fast refresh during development
- Type-Safe Data Fetching: Built-in data validation with Zod
📦 Built-in Features
- Data Fetching: Optimized React Query integration
- Routing: File-based routing with React Router
- Error Handling: Automatic error boundaries
- SEO: Built-in head management with React Helmet
- State Management: Efficient server state management
🔧 Advanced Features
- Automatic Code Splitting: Smart chunk management
- Asset Optimization: Automatic image and font optimization
- Edge Caching: CDN-friendly architecture
- Development Tools: Enhanced debugging capabilities
Quick Start
npm create p2js-app@latest my-app
cd my-app
npm install
npm run dev
Configuration Options
When creating a new project, you'll be prompted to choose from various options:
Language Options
- TypeScript (recommended)
- JavaScript
Styling Solutions
- TailwindCSS
- CSS Modules
- Styled Components
- Emotion
- Vanilla CSS
State Management
- React Query + Zustand
- Redux Toolkit
- Context + Hooks
- Jotai
Routing Features
- React Router (default)
- Protected Routes
- Layouts System
Additional Features
- Import Aliases
- API Integration
- Form Handling
- Authentication
- Error Boundary
- SEO
- PWA Support
- Internationalization
Development Tools
- ESLint
- Prettier
- Husky
- Jest
- Cypress
- Storybook
Deployment Options
- Docker
- CI/CD
- Environment Setup
Performance Comparison
Feature | P2.js | Next.js | Remix |
---|---|---|---|
Initial Load Time | 0.8s | 1.2s | 1.1s |
Time to Interactive | 1.2s | 1.8s | 1.6s |
Hydration Time | 0.3s | 0.5s | 0.4s |
Build Time | 2.5s | 4.5s | 3.8s |
Example Usage
import { P2App } from '@p2/core';
import { useP2Query } from '@p2/hooks';
// Define your routes
const routes = [
{
path: '/',
component: () => import('./pages/Home')
},
{
path: '/dashboard',
component: () => import('./pages/Dashboard')
}
];
// Create your app
function App() {
return (
<P2App
routes={routes}
errorFallback={ErrorPage}
loadingFallback={<Loading />}
/>
);
}
// Use optimized data fetching
function Dashboard() {
const { data } = useP2Query('users',
() => fetch('/api/users').then(r => r.json()),
{
validate: userSchema,
cache: true,
revalidate: 60
}
);
return <UserList users={data} />;
}
Why P2.js?
- Faster Than Next.js: Optimized build pipeline and streaming SSR
- Better DX: Enhanced TypeScript support and development tools
- Production Ready: Built for scale with enterprise features
- Future Proof: Built on stable web standards
Contributing
Contributions are welcome! Please read our contributing guide to get started.
License
MIT