0.1.7 • Published 8 months ago

create-p2js-app v0.1.7

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

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

FeatureP2.jsNext.jsRemix
Initial Load Time0.8s1.2s1.1s
Time to Interactive1.2s1.8s1.6s
Hydration Time0.3s0.5s0.4s
Build Time2.5s4.5s3.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