0.0.360 โ€ข Published 4 months ago

0x1 v0.0.360

Weekly downloads
-
License
TDLv1
Repository
github
Last release
4 months ago

โšก Features

๐Ÿ’จ Extreme Performance

  • Tiny runtime: <30KB total JS bundle size
  • Zero hydration cost: No client-side hydration overhead
  • Native ESM: Browser-native module loading without bundling
  • Precomputed content: Minimal JS for maximum speed
  • Sub-second builds: Bun-powered compilation and bundling

๐Ÿ”„ React/Next.js Drop-in Replacement

  • Full React Hooks API: useState, useEffect, useCallback, useMemo, useRef
  • Next.js-compatible Link: Drop-in replacement for next/link
  • App Directory Structure: Next15-style file-based routing
  • JSX Runtime: Custom JSX implementation without React dependencies
  • Efficient Server Actions: "use server" functions with automatic internal API generation (never exposed publicly)
  • Explicitly Split Client/Server: Simply use "use server" for server-side functions and "use client" for client-side components, or leave it up to 0x1 to automatically infer the context
  • Easy Migration: Simple find-and-replace from React/Next.js imports

๐Ÿงฉ Component System

  • TypeScript-Only: Exclusively built for TypeScript with full type safety
  • Simple API: Modern component system, Next15-compatible, but without the bloat
  • Minimal abstractions: Near-vanilla performance with type-checked templates
  • Custom Diffing: Optimized DOM updates with TypeScript safety
  • Compile-time validation: Catch errors early with strict typing
  • Smart Context Inference: Automatically detects client/server context and validates usage
  • Runtime Error Boundaries: Beautiful error display for development with helpful suggestions

๐Ÿ“ App Directory Structure

  • Next15-compatible: Modern app directory structure with file-based routing
  • Nested layouts: Component co-location and shared UI
  • Special file conventions: page.tsx, layout.tsx, loading.tsx, not-found.tsx, etc.
  • Zero configuration: Works out of the box

๐Ÿ›ฃ๏ธ Advanced Routing System

  • Dynamic routes: [slug], [...slug], [[...slug]] patterns
  • Route groups: (auth) folders that don't affect URL structure
  • Search params: Next15-style useSearchParams, useParams, usePathname
  • Route conflict detection: Automatic detection and resolution of conflicting routes
  • Hash fragment navigation: Proper #anchor link handling with auto-scroll
  • Nested layouts: Automatic composition of multiple layout levels

๐Ÿ”จ Developer Experience

  • Bun-first architecture: Fully optimized for Bun's capabilities
  • Lightning-fast hot reload: Sub-second refresh times using SSE + WebSocket
  • Beautiful dev server output: Clear status codes, routes, and component info
  • Tailwind CSS v4 integration: Zero-config styling with automatic optimization
  • Smart defaults: Sensible configurations out of the box

๐Ÿ“ฑ Progressive Web App Support

  • Auto-generated PWA assets: Icons, splash screens, and manifest
  • Offline support: Service worker with intelligent caching
  • Install prompts: Native app-like experience
  • Dark/light modes: Theme support for your PWA
  • Push notifications: Ready infrastructure

๐Ÿ’ก Philosophy

0x1's philosophy is radically different from most modern frameworks:

  1. Zero abstraction cost: No virtual DOM or complex state tracking
  2. Browser-native: Leverage what browsers are good at
  3. Minimal over comprehensive: Focused feature set, exceptional at few things
  4. No dependencies: Entire framework in one tiny package
  5. Extreme performance: Optimize for loaded page performance, not DX shortcuts
  6. TypeScript-first: Built exclusively for TypeScript with full type safety

๐Ÿš€ Quickstart

Prerequisites

  • Bun v1.0.0 or higher (REQUIRED)

Installation

# Install globally (recommended)
bun install -g 0x1

# Or use npx for one-off commands
npx 0x1@latest new my-app

Create a New Project

# Create a new project with default options
0x1 new my-app

# Select template complexity
0x1 new my-app --complexity=minimal|standard|full

# With additional options
0x1 new my-app --theme="royal-purple" --pwa

Development

# Navigate to your project
cd my-app

# Start the development server
0x1 dev

# Open http://localhost:3000 to view your app

Port Management: If port 3000 is in use, the dev server automatically finds the next available port.

Build and Deploy

# Create a production build
0x1 build

# Preview your production build locally
0x1 preview

# Deploy to production
0x1 deploy --provider=vercel

๐ŸŽจ CSS Configuration

0x1 provides intelligent CSS processing with multiple options for optimal performance. Configure your CSS processor in your 0x1.config.ts file:

Configuration Options

// 0x1.config.ts
export default {
  css: {
    processor: '0x1-enhanced', // or 'tailwind-v4'
    minify: true,
    sourcemap: true,
    outputPath: 'dist/styles/output.css',
    content: [
      'src/**/*.{js,ts,jsx,tsx,html}',
      'components/**/*.{js,ts,jsx,tsx,html}',
      'pages/**/*.{js,ts,jsx,tsx,html}',
      'app/**/*.{js,ts,jsx,tsx,html}'
    ],
    darkMode: 'class', // or 'media'
    theme: {
      extend: {
        colors: {
          brand: '#0066cc'
        }
      }
    },
    plugins: []
  }
};

CSS Processors

๐Ÿš€ 0x1 Enhanced (Recommended)

Intelligent Tailwind CSS processor with dramatic performance improvements

  • Performance: 88% faster builds (<400ms vs 4801ms baseline)
  • Bundle Size: 95% smaller bundles (5.76KB vs 97KB)
  • Smart Delegation: Automatically uses your installed Tailwind packages
  • Multi-Strategy Processing: CLI โ†’ PostCSS โ†’ File discovery โ†’ Fallback
  • Version Aware: Supports both Tailwind v3 and v4 automatically
  • Intelligent Caching: Hash-based cache invalidation with dependency tracking
export default {
  css: {
    processor: '0x1-enhanced' // Default for new projects
  }
};

๐ŸŒˆ Tailwind v4 (Standard)

Standard TailwindCSS v4 processing

  • Official Support: Uses the official TailwindCSS v4 engine
  • Full Features: Complete Tailwind feature set and plugin ecosystem
  • Predictable Output: Consistent with standard Tailwind builds
  • Slower Performance: Standard build times (3000ms+ for large projects)
export default {
  css: {
    processor: 'tailwind-v4'
  }
};

Performance Comparison

ScenarioTailwindCSS v40x1 EnhancedImprovement
Fresh build4,801ms559ms88% faster
Bundle size97KB5.76KB95% smaller
Large project8,000ms+<1000ms87% faster
Memory usageHighLow (streaming)60% less

Advanced Configuration

// 0x1.config.ts - Advanced CSS configuration
export default {
  css: {
    processor: '0x1-enhanced',
    
    // Output configuration
    minify: process.env.NODE_ENV === 'production',
    sourcemap: process.env.NODE_ENV === 'development',
    outputPath: 'dist/styles/app.css',
    
    // Content scanning
    content: [
      'app/**/*.{js,ts,jsx,tsx}',
      'components/**/*.{js,ts,jsx,tsx}',
      'lib/**/*.{js,ts,jsx,tsx}',
      // Add your content paths
    ],
    
    // Performance options (0x1-enhanced only)
    purge: true, // Remove unused styles
    
    // Tailwind configuration
    darkMode: 'class',
    theme: {
      extend: {
        fontFamily: {
          sans: ['Inter', 'system-ui', 'sans-serif'],
        },
        colors: {
          primary: {
            50: '#eff6ff',
            500: '#3b82f6',
            900: '#1e3a8a',
          }
        }
      }
    },
    
    // Tailwind plugins
    plugins: [
      // '@tailwindcss/forms',
      // '@tailwindcss/typography'
    ]
  }
};

How 0x1 Enhanced Works

The 0x1-enhanced processor uses intelligent delegation with multiple strategies:

  1. File Discovery: Automatically finds CSS files in standard locations
  2. Directive Detection: Identifies Tailwind v3 (@tailwind) vs v4 (@import "tailwindcss") syntax
  3. Smart Processing: Processes through your installed Tailwind packages via PostCSS
  4. Graceful Fallback: Provides essential CSS if processing fails
  5. Bundle Optimization: Avoids bundling large CSS utilities in JavaScript

Development vs Production

The CSS processor automatically optimizes for different environments:

Development Mode:

  • Fast incremental builds with caching
  • Source maps for debugging
  • Hot reload integration
  • Detailed build logging

Production Mode:

  • Minified output
  • Purged unused styles
  • Optimized file sizes
  • Cache-busting headers

Migration from TailwindCSS

If you're migrating from a pure TailwindCSS project:

  1. Keep your existing tailwind.config.js - 0x1 will automatically detect and use it
  2. Update your configuration to use 0x1's CSS system:
// Before: tailwind.config.js
module.exports = {
  content: ['./src/**/*.{js,ts,jsx,tsx}'],
  theme: { extend: {} },
  plugins: []
};

// After: 0x1.config.ts
export default {
  css: {
    processor: '0x1-enhanced',
    content: ['./src/**/*.{js,ts,jsx,tsx}'],
    theme: { extend: {} },
    plugins: []
  }
};
  1. Choose your processor: Start with '0x1-enhanced' for maximum performance, fallback to 'tailwind-v4' if needed

Troubleshooting

Slow builds?

  • Switch to processor: '0x1-enhanced' for 88% faster builds
  • Reduce content patterns to only include necessary files
  • Enable purge: true to remove unused styles

Missing styles?

  • Check your content patterns include all component files
  • Verify your Tailwind classes are spelled correctly
  • Use processor: 'tailwind-v4' as fallback for full compatibility

Large bundle sizes?

  • Use processor: '0x1-enhanced' for 95% smaller bundles
  • Avoid importing Tailwind CSS in JavaScript files
  • Enable purge: true for production builds

Cache issues?

  • The 0x1 Enhanced processor automatically invalidates cache when classes change
  • For manual cache clearing, delete .0x1-cache/ directory

๐Ÿ“‹ Template Options

๐Ÿ” Minimal Template

Ideal for: Small projects, landing pages, or developers who want full control

  • Basic structure with essential files only
  • Perfect for landing pages or simple sites
  • Tailwind CSS included
  • Extremely lightweight with minimal dependencies

๐Ÿงฉ Standard Template

Ideal for: Most web applications and sites

  • Complete project structure with organized files
  • Router implementation with multi-page support
  • Component architecture for building complex UIs
  • Tailwind CSS with dark mode support
  • Common utility functions and helpers

๐Ÿš€ Full Template

Ideal for: Production applications with advanced features

  • Everything in Standard, plus:
  • Built-in state management system
  • Progressive Web App (PWA) support
  • Service worker for offline capabilities
  • Advanced components with animations
  • Background sync for offline form submissions
  • Push notification infrastructure

๐ŸŽฏ Metadata & SEO Management

0x1 provides a Next15-compatible metadata system that works automatically without requiring manual imports or function calls.

Static Metadata Export

Simply export a metadata constant from any page or layout:

// app/page.tsx
export const metadata = {
  title: 'Home Page',
  description: 'Welcome to my awesome app',
  keywords: ['nextjs', '0x1', 'typescript'],
  openGraph: {
    title: 'Home Page',
    description: 'Welcome to my awesome app',
    images: ['/og-image.jpg'],
  },
  twitter: {
    card: 'summary_large_image',
    title: 'Home Page',
    description: 'Welcome to my awesome app',
  }
};

export default function HomePage() {
  return <h1>Welcome!</h1>;
}

Global Metadata Configuration

Create a global metadata configuration in app/metadata.ts:

// app/metadata.ts
export const metadata = {
  title: {
    template: '%s | My App',
    default: 'My App'
  },
  description: 'A modern web application built with 0x1',
  keywords: ['0x1', 'framework', 'typescript'],
  
  // SEO
  robots: {
    index: true,
    follow: true,
  },
  
  // Social Media
  openGraph: {
    type: 'website',
    locale: 'en_US',
    url: 'https://myapp.com',
    siteName: 'My App',
  },
  
  // PWA & Mobile
  viewport: {
    width: 'device-width',
    initialScale: 1,
  },
  themeColor: '#000000',
  manifest: '/manifest.json',
  
  // Icons
  icons: {
    icon: '/favicon.ico',
    apple: '/apple-touch-icon.png',
  },
};

Page-Specific Metadata

Override global metadata for specific pages:

// app/pages/about/page.tsx
export const metadata = {
  title: 'About Us',
  description: 'Learn more about our company',
  openGraph: {
    title: 'About Us',
    description: 'Learn more about our company',
  }
};

export default function AboutPage() {
  return <div>About us content...</div>;
}

Dynamic Metadata

For dynamic metadata based on props or data:

// app/pages/blog/[slug]/page.tsx
export async function generateMetadata({ params }: { params: { slug: string } }) {
  const post = await fetchPost(params.slug);
  
  return {
    title: post.title,
    description: post.excerpt,
    openGraph: {
      title: post.title,
      description: post.excerpt,
      images: [post.image],
    }
  };
}

export default function BlogPost({ params }: { params: { slug: string } }) {
  // Component implementation
}

Client/Server Directives

0x1 supports Next15-style client and server directives for clear separation of concerns.

Client Components

Use "use client" for browser-only components:

"use client";

import { useState } from 'react';

export default function Counter() {
  const [count, setCount] = useState(0);
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
    </div>
  );
}

Server Actions

Use "use server" for server-side functions:

"use server";

// app/actions/user-actions.ts
export async function fetchUserData(userId: string) {
  const response = await fetch(`/api/users/${userId}`);
  return response.json();
}

export async function updateUserProfile(userId: string, data: any) {
  const response = await fetch(`/api/users/${userId}`, {
    method: 'PUT',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(data)
  });
  
  if (!response.ok) {
    throw new Error('Failed to update profile');
  }
  
  return response.json();
}

Using Server Actions in Client Components

"use client";

import { fetchUserData, updateUserProfile } from '../actions/user-actions';

export default function UserProfile({ userId }: { userId: string }) {
  const [user, setUser] = useState(null);
  
  useEffect(() => {
    fetchUserData(userId).then(setUser);
  }, [userId]);
  
  const handleUpdate = async (data: any) => {
    try {
      await updateUserProfile(userId, data);
      // Refresh user data
      const updatedUser = await fetchUserData(userId);
      setUser(updatedUser);
    } catch (error) {
      console.error('Update failed:', error);
    }
  };
  
  return (
    <div>
      {/* User profile UI */}
    </div>
  );
}

Automatic API Generation

Server actions automatically create internal API endpoints:

  • Functions in "use server" files become callable from client components
  • Zero exposed endpoints: Internal API generation means no public API routes to secure or document
  • Automatic type safety: Full TypeScript safety maintained across the client/server boundary
  • No manual API creation: Skip the boilerplate of creating /api/ routes manually
  • Built-in security: Server actions are never exposed to the client, only used for server-side logic
  • Simplified architecture: Call server functions directly from client components without HTTP overhead

Best Practices

  1. Metadata: Always export const metadata = {} for static metadata
  2. Client Components: Use "use client" only when necessary (state, events, browser APIs)
  3. Server Actions: Use "use server" for data fetching, mutations, and server-side logic
  4. Type Safety: Leverage TypeScript for full type safety across client/server boundaries

PWA Integration

When creating a PWA project, metadata is automatically configured:

0x1 new my-pwa-app --pwa --theme-color="#007acc"

This automatically generates:

  • Manifest file with proper metadata
  • Icon files in multiple sizes
  • Service worker for offline support
  • Metadata configuration with PWA-specific tags

๐Ÿ”„ Migration from React/Next.js

0x1 is designed as a drop-in replacement for React and Next.js applications. Migration is as simple as updating your imports:

Quick Migration Guide

1. Replace React imports:

// Before (React)
import React, { useState, useEffect } from 'react';

// After (0x1)
import { useState, useEffect } from '0x1';

2. Replace Next.js Link imports:

// Before (Next.js)
import Link from 'next/link';

// After (0x1)
import Link from '0x1/link';

3. Replace Next.js router imports:

// Before (Next.js)
import { useRouter } from 'next/router';

// After (0x1)
import { useRouter } from '0x1/router';

Automated Migration

Use this one-liner to migrate most imports automatically:

# Replace React imports
find ./src -name "*.tsx" -o -name "*.ts" | xargs sed -i 's/from ['\''"]react['\''"];/from "0x1";/g'

# Replace Next.js Link imports
find ./src -name "*.tsx" -o -name "*.ts" | xargs sed -i 's/from ['\''"]next\/link['\''"];/from "0x1\/link";/g'

# Replace Next.js router imports
find ./src -name "*.tsx" -o -name "*.ts" | xargs sed -i 's/from ['\''"]next\/router['\''"];/from "0x1\/router";/g'

Supported React Features

โœ… Fully Supported:

  • useState - State management
  • useEffect - Side effects and lifecycle
  • useCallback - Function memoization
  • useMemo - Value memoization
  • useRef - DOM references and mutable values
  • JSX syntax and components
  • Component props and children
  • Event handlers (onClick, onChange, etc.)

โœ… 0x1 Enhanced Features:

  • useFetch - Built-in data fetching with loading states
  • useForm - Form state management with validation
  • useLocalStorage - Persistent state with localStorage
  • useClickOutside - Click outside detection

โœ… Next.js Compatibility:

  • Link component with href prop
  • App directory structure (app/page.tsx, app/layout.tsx)
  • File-based routing
  • useRouter hook for navigation

Component Migration Example

Before (React/Next.js):

import React, { useState, useEffect } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';

export default function MyComponent() {
  const [count, setCount] = useState(0);
  const router = useRouter();

  useEffect(() => {
    console.log('Component mounted');
  }, []);

  return (
    <div>
      <h1>Count: {count}</h1>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
      <Link href="/about">
        <a>About Page</a>
      </Link>
    </div>
  );
}

After (0x1):

import { useState, useEffect } from '0x1';
import Link from '0x1/link';
import { useRouter } from '0x1/router';

export default function MyComponent() {
  const [count, setCount] = useState(0);
  const router = useRouter();

  useEffect(() => {
    console.log('Component mounted');
  }, []);

  return (
    <div>
      <h1>Count: {count}</h1>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
      <Link href="/about">About Page</Link>
    </div>
  );
}

๐Ÿงฉ Component System

0x1 offers a simple but powerful component system built with TypeScript:

// No React import needed! 0x1 has its own JSX runtime

interface ButtonProps {
  onClick: () => void;
  children: string;
  variant?: 'primary' | 'secondary';
}

export function Button({ onClick, children, variant = 'primary' }: ButtonProps) {
  return (
    <button
      className={`btn btn-${variant}`}
      onClick={onClick}
    >
      {children}
    </button>
  );
}

// Usage
function App() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <h1>Count: {count}</h1>
      <Button onClick={() => setCount(count + 1)}>
        Increment
      </Button>
    </div>
  );
}

Hooks API

0x1 provides a complete React-compatible hooks API:

import { 
  useState, 
  useEffect, 
  useCallback, 
  useMemo, 
  useRef,
  useFetch,
  useForm,
  useLocalStorage 
} from '0x1';

function MyComponent() {
  // State management
  const [count, setCount] = useState(0);
  
  // Side effects
  useEffect(() => {
    document.title = `Count: ${count}`;
  }, [count]);
  
  // Memoization
  const expensiveValue = useMemo(() => {
    return count * 1000;
  }, [count]);
  
  // Callbacks
  const handleClick = useCallback(() => {
    setCount(prev => prev + 1);
  }, []);
  
  // Refs
  const inputRef = useRef<HTMLInputElement>(null);
  
  // Data fetching (0x1 enhanced)
  const { data, loading, error } = useFetch('/api/data');
  
  // Persistent state (0x1 enhanced)
  const [theme, setTheme] = useLocalStorage('theme', 'dark');
  
  return (
    <div>
      <input ref={inputRef} />
      <button onClick={handleClick}>
        Count: {count} (Expensive: {expensiveValue})
      </button>
      {loading && <p>Loading...</p>}
      {data && <pre>{JSON.stringify(data, null, 2)}</pre>}
    </div>
  );
}

๐Ÿ“ App Directory Structure

0x1 uses the modern Next15patible app directory structure:

my-app/
โ”œโ”€โ”€ app/                    # App directory (Next15-style)
โ”‚   โ”œโ”€โ”€ layout.tsx          # Root layout (required)
โ”‚   โ”œโ”€โ”€ page.tsx            # Home page
โ”‚   โ”œโ”€โ”€ not-found.tsx       # 404 page
โ”‚   โ”œโ”€โ”€ about/
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx        # /about route
โ”‚   โ”œโ”€โ”€ blog/
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx      # Nested layout for blog
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx        # /blog route
โ”‚   โ”‚   โ””โ”€โ”€ [slug]/
โ”‚   โ”‚       โ””โ”€โ”€ page.tsx    # /blog/[slug] dynamic route
โ”‚   โ””โ”€โ”€ api/
โ”‚       โ””โ”€โ”€ hello/
โ”‚           โ””โ”€โ”€ route.ts    # API route
โ”œโ”€โ”€ components/             # Reusable components
โ”‚   โ”œโ”€โ”€ Button.tsx
โ”‚   โ”œโ”€โ”€ Header.tsx
โ”‚   โ””โ”€โ”€ ThemeToggle.tsx
โ”œโ”€โ”€ lib/                    # Utilities and helpers
โ”œโ”€โ”€ public/                 # Static assets
โ”œโ”€โ”€ styles/                 # CSS files
โ”‚   โ””โ”€โ”€ globals.css
โ”œโ”€โ”€ 0x1.config.ts          # Framework configuration
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

Special Files

  • layout.tsx - Shared UI for a segment and its children
  • page.tsx - Unique UI of a route and makes it publicly accessible
  • loading.tsx - Loading UI for a segment and its children
  • error.tsx - Error UI for a segment and its children
  • not-found.tsx - UI for 404 errors

Example Layout

// app/layout.tsx
import { ThemeToggle } from '../components/ThemeToggle';
import Link from '0x1/link';

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <header>
          <nav>
            <Link href="/">Home</Link>
            <Link href="/about">About</Link>
            <ThemeToggle />
          </nav>
        </header>
        <main>{children}</main>
      </body>
    </html>
  );
}

๐Ÿ—บ๏ธ Routing & Navigation

Link Component

0x1 provides a Next.js-compatible Link component:

import Link from '0x1/link';

function Navigation() {
  return (
    <nav>
      <Link href="/">Home</Link>
      <Link href="/about">About</Link>
      <Link href="/blog">Blog</Link>
      
      {/* With custom styling */}
      <Link href="/contact" className="nav-link">
        Contact
      </Link>
      
      {/* Hash fragment navigation */}
      <Link href="/docs/api#hooks">
        API Hooks Section
      </Link>
      
      {/* External links work normally */}
      <Link href="https://example.com" target="_blank">
        External Link
      </Link>
    </nav>
  );
}

Dynamic Routes

0x1 supports Next.js 15-style dynamic routing:

app/
โ”œโ”€โ”€ page.tsx                    // matches /
โ”œโ”€โ”€ about/page.tsx             // matches /about
โ”œโ”€โ”€ blog/
โ”‚   โ”œโ”€โ”€ [slug]/page.tsx        // matches /blog/hello-world
โ”‚   โ””โ”€โ”€ [...tags]/page.tsx     // matches /blog/tag1/tag2/etc
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ [[...path]]/page.tsx   // matches /docs, /docs/api, /docs/api/hooks
โ”‚   โ””โ”€โ”€ (auth)/                // Route group - doesn't affect URL
โ”‚       โ”œโ”€โ”€ login/page.tsx     // matches /login (not /auth/login)
โ”‚       โ””โ”€โ”€ register/page.tsx  // matches /register
โ””โ”€โ”€ [category]/
    โ””โ”€โ”€ [id]/page.tsx          // matches /electronics/123

Search Parameters & Navigation

Access URL search parameters and navigation in your components:

import { useSearchParams, useParams, useRouter } from '0x1/router';

function ProductPage() {
  const params = useParams<{ category: string; id: string }>();
  const searchParams = useSearchParams();
  const router = useRouter();
  
  const color = searchParams.get('color');
  const size = searchParams.get('size');
  
  const handleNavigate = () => {
    // Navigate with custom scroll behavior
    router.navigate('/products', true, 'smooth');
  };
  
  return (
    <div>
      <h1>Product {params.id} in {params.category}</h1>
      {color && <p>Color: {color}</p>}
      {size && <p>Size: {size}</p>}
    </div>
  );
}

Scroll Behavior

0x1 provides intelligent scroll management that follows modern SPA best practices:

Default Behavior:

  • New navigation: Scroll to top โœ…
  • Browser back/forward: Preserve scroll position โœ…
  • Hash fragments: Scroll to target element โœ…
  • External links: Normal browser behavior โœ…

Router Configuration:

// Global scroll behavior
const router = new Router({
  scrollBehavior: 'auto',    // Smart default (recommended)
  // scrollBehavior: 'top',     // Always scroll to top
  // scrollBehavior: 'preserve', // Never scroll
  // scrollBehavior: 'smooth',   // Smooth scroll to top
});

Per-Link Overrides:

import Link from '0x1/link';

function Navigation() {
  return (
    <nav>
      {/* Default behavior */}
      <Link href="/products">Products</Link>
      
      {/* Always scroll to top */}
      <Link href="/about" scrollBehavior="top">About</Link>
      
      {/* Preserve scroll position */}
      <Link href="/settings" scrollBehavior="preserve">Settings</Link>
      
      {/* Smooth scroll to top */}
      <Link href="/contact" scrollBehavior="smooth">Contact</Link>
      
      {/* Hash fragment navigation */}
      <Link href="/docs/api#hooks">API Hooks</Link>
    </nav>
  );
}

Programmatic Navigation:

const router = useRouter();

// Default behavior
router.navigate('/products');

// Custom scroll behavior
router.navigate('/about', true, 'smooth');
router.navigate('/settings', true, 'preserve');

๐ŸŽจ Styling with Tailwind CSS

0x1 includes automatic Tailwind CSS v4 processing:

Zero-Config Setup

# Install Tailwind CSS
bun add -d tailwindcss@next @tailwindcss/postcss autoprefixer

# Create config (optional - 0x1 provides defaults)
bunx tailwindcss init

# Start development (Tailwind is processed automatically)
0x1 dev

Usage in Components

export function Card({ children }: { children: React.ReactNode }) {
  return (
    <div className="p-6 bg-white dark:bg-gray-800 rounded-lg shadow-lg hover:shadow-xl transition-shadow">
      {children}
    </div>
  );
}

export function Button({ variant = 'primary', children, ...props }) {
  const baseClasses = "px-4 py-2 rounded-lg font-medium transition-colors";
  const variantClasses = {
    primary: "bg-blue-600 hover:bg-blue-700 text-white",
    secondary: "bg-gray-200 hover:bg-gray-300 text-gray-900"
  };

  return (
    <button 
      className={`${baseClasses} ${variantClasses[variant]}`}
      {...props}
    >
      {children}
    </button>
  );
}

๐Ÿ“ฑ Progressive Web App Support

Add PWA functionality to any project:

# Add PWA during project creation
0x1 new my-app --pwa --theme="royal-purple"

# Add PWA to existing project
0x1 pwa

PWA Features

  • Auto-generated assets: Icons, splash screens, manifest
  • Offline support: Service worker with intelligent caching
  • Install prompts: Native app-like experience
  • Theme support: Dark/light modes for your PWA
  • Push notifications: Ready infrastructure

PWA Configuration Options

# Full customization
0x1 pwa --name "My App" \
         --shortName "App" \
         --themeColor "#0077cc" \
         --backgroundColor "#ffffff" \
         --description "My awesome PWA application" \
         --icons \
         --offline \
         --skipPrompts

๐Ÿ”ง CLI Commands

CommandDescription
0x1 new <name>Create a new 0x1 project
0x1 devStart development server with hot reload
0x1 buildCreate optimized production build
0x1 previewPreview production build locally
0x1 deployDeploy to production (Vercel, Netlify)
0x1 pwaAdd Progressive Web App functionality
0x1 generate component <name>Generate a component
0x1 generate page <name>Generate a page

Development Options

# Start with custom port
0x1 dev --port=8080

# Enable debug logging
0x1 dev --debug

# Skip Tailwind processing
0x1 dev --skip-tailwind

Template Options

# Create with specific template
0x1 new my-app --complexity=minimal    # Basic structure
0x1 new my-app --complexity=standard   # Complete project structure
0x1 new my-app --complexity=full       # Everything + PWA + advanced features

# With theme and PWA
0x1 new my-app --theme="royal-purple" --pwa

๐Ÿš€ Deployment

0x1 projects are optimized for modern hosting platforms:

# Deploy to Vercel (recommended)
0x1 deploy --provider=vercel

# Deploy to Netlify
0x1 deploy --provider=netlify

# Custom deployment
0x1 build
# Then deploy the 'dist' directory

The framework is specially optimized for:

  • Vercel Edge Runtime - Maximum performance at the edge
  • Netlify Edge Functions - Fast global deployment
  • Cloudflare Workers - Ultra-low latency worldwide
  • Static hosting - Works with any static host

๐Ÿ“Š Performance Comparison

Metric0x1ReactNext.jsVueSvelte
Bundle Size (gzipped)5KB44KB80KB+31KB4-21KB
Time to Interactive0.3s1.1s1.5s+0.7s0.6s
Memory UsageLowHighHighMediumLow
Lighthouse Score10075-8570-8585-9590-95
Cold Start Time<100ms300ms+500ms+200ms+150ms+

๐Ÿ”ฎ Roadmap

Current State (v0.0.360)

  • โœ… Full React Hooks API compatibility
  • โœ… "use server" & "use client" directives
  • โœ… Next.js-compatible Link component
  • โœ… App directory structure support
  • โœ… Tailwind CSS v4 integration
  • โœ… PWA support with auto-generated assets
  • โœ… TypeScript-first development
  • โœ… Bun-optimized build system
  • โœ… SSE + WebSocket live reload
  • โœ… Zero-dependency architecture
  • โœ… Simplified, reliable hooks implementation
  • โœ… Auto-context inference with directive validation

Upcoming Features

  • ๐Ÿ”„ Enhanced Error Boundaries: React-error-boundary & next-error-boundary compatibility
  • ๐Ÿ”„ Streaming SSR: Server-side rendering with streaming (in progress)
  • ๐Ÿ”„ Edge Runtime: Optimized edge deployment
  • ๐Ÿš€ Crypto Template: Wallet Connect, NFT viewing, DeFi dashboard components

๐Ÿ› ๏ธ Configuration

0x1 configuration is minimal and straightforward:

// 0x1.config.ts
import { _0x1Config } from '0x1';

const config: _0x1Config = {
  app: {
    name: 'my-0x1-app',
    title: 'My 0x1 App',
    description: 'Built with 0x1 framework'
  },
  server: {
    port: 3000,
    host: 'localhost',
    basePath: '/'
  },
  routes: {
    '/': './pages/home',
    '/about': './pages/about',
    '/products/:id': './pages/product'
  },
  styling: {
    tailwind: true,
    darkMode: 'class',
    customTheme: {
      colors: {
        primary: '#0077cc'
      }
    }
  },
  optimization: {
    minify: true,
    precomputeTemplates: true,
    prefetchLinks: true
  },
  deployment: {
    provider: 'vercel', // or 'netlify', 'cloudflare', etc.
    edge: true
  }
};

export default config;

๐Ÿ”ง Troubleshooting

Global CLI Installation Issues

If you encounter command not found: 0x1 after installing globally:

# Alternative way to run any 0x1 command
bunx 0x1 <command>

# Or add Bun's bin directory to your PATH:
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

Content Not Showing in Browser

  1. Check Browser Console: Look for MIME type errors
  2. Build Process: Run bun run build before starting dev server
  3. TypeScript Compilation: The dev server automatically handles TypeScript

๐Ÿ’ฌ Community & Support


๐Ÿ‘ท Contributing

Contributions are welcome! Here's how you can help:

# Clone the repository
git clone https://github.com/Triex/0x1.git
cd 0x1

# Install dependencies
bun install

# Run tests
bun test

# Build the framework
bun run build

Please see our Contributing Guidelines for more details.


Pending Features

Actual project intent is to allow development in Next/React styles-flows-APIs that everyone is used to, but allow devs to instantly spin up what usually takes hours of work, with the added benefit of Bun's speed and zero overhead dependencies (magnitudes' faster than Next/React bolt in replacement).

Another key point is that AI's understand Next/React, and can generate code for it. So this makes 0x1 a super speed way for vibe-coders to build websites, and apps as AI advances. (Currently quite stable for basics). Pending solid website & documentation.

Ultimately; adding crypto features to give the framework a real use case, and ability to grow rapidly. (Hence 0x1)

  • Create robust tests for all features, and ensure they are working as expected. (e2e & unit)
  • Crypto template option with various crypto features as options, inc;
    • Wallet Connect, basic connect for ERC20 EVM tokens, and SOL, etc. OR allow all chains.
    • Coin dApp / Dashboard, view connected wallet coin holdings, transactions + coin price, market cap, etc as appropriate.
    • NFT, NFT viewing UI, basic NFT minting and collection features.
  • Audit / ensure stable app router functionality ("use server", "use client" tags work, page.tsx actions.ts work)
  • Functional templates
    • Minimal
    • Standard (drafted, todo)
    • Full (drafted, todo)
  • Full ErrorBoundary support, like react-error-boundary or next-error-boundary
  • Initial draft of bolt-in react hooks, with loading states, error handling, and caching.
    • Properly tested, and documented. Confirmed functional.
  • Create 0x1 Website with documentation, examples, and tutorials.
    • Add in-browser AI Component IDE Generator tool (paid LLM API)

๐Ÿ“œ License

0x1 is licensed under the TDL v1 License.


0.0.360

4 months ago

0.0.359

4 months ago

0.0.358

4 months ago

0.0.357

4 months ago

0.0.356

4 months ago

0.0.355

4 months ago

0.0.354

4 months ago

0.0.353

4 months ago

0.0.352

4 months ago

0.0.351

4 months ago

0.0.350

4 months ago

0.0.349

4 months ago

0.0.348

4 months ago

0.0.347

4 months ago

0.0.346

4 months ago

0.0.345

4 months ago

0.0.344

4 months ago

0.0.343

4 months ago

0.0.342

4 months ago

0.0.341

4 months ago

0.0.340

4 months ago

0.0.339

4 months ago

0.0.337

4 months ago

0.0.336

4 months ago

0.0.335

4 months ago

0.0.334

4 months ago

0.0.333

4 months ago

0.0.332

4 months ago

0.0.331

4 months ago

0.0.330

4 months ago

0.0.329

4 months ago

0.0.328

4 months ago

0.0.327

4 months ago

0.0.326

4 months ago

0.0.325

4 months ago

0.0.324

4 months ago

0.0.323

4 months ago

0.0.322

4 months ago

0.0.321

4 months ago

0.0.320

4 months ago

0.0.319

4 months ago

0.0.318

4 months ago

0.0.317

4 months ago

0.0.316

4 months ago

0.0.315

4 months ago

0.0.314

4 months ago

0.0.313

4 months ago

0.0.312

4 months ago

0.0.311

4 months ago

0.0.310

4 months ago

0.0.309

4 months ago

0.0.308

4 months ago

0.0.307

4 months ago

0.0.306

4 months ago

0.0.305

4 months ago

0.0.304

4 months ago

0.0.303

4 months ago

0.0.302

4 months ago

0.0.301

4 months ago

0.0.300

4 months ago

0.0.299

4 months ago

0.0.298

4 months ago

0.0.297

4 months ago

0.0.296

4 months ago

0.0.295

4 months ago

0.0.294

4 months ago

0.0.293

4 months ago

0.0.292

4 months ago

0.0.291

4 months ago

0.0.290

4 months ago

0.0.289

4 months ago

0.0.288

4 months ago

0.0.287

4 months ago

0.0.286

4 months ago

0.0.285

4 months ago

0.0.284

4 months ago

0.0.283

4 months ago

0.0.282

4 months ago

0.0.281

4 months ago

0.0.280

4 months ago

0.0.279

4 months ago

0.0.278

4 months ago

0.0.277

4 months ago

0.0.276

4 months ago

0.0.275

4 months ago

0.0.274

4 months ago

0.0.273

4 months ago

0.0.272

4 months ago

0.0.271

4 months ago

0.0.270

4 months ago

0.0.269

4 months ago

0.0.268

4 months ago

0.0.267

4 months ago

0.0.266

4 months ago

0.0.265

4 months ago

0.0.264

4 months ago

0.0.263

4 months ago

0.0.262

4 months ago

0.0.261

4 months ago

0.0.260

4 months ago

0.0.259

4 months ago

0.0.258

4 months ago

0.0.257

4 months ago

0.0.256

4 months ago

0.0.255

4 months ago

0.0.254

4 months ago

0.0.253

4 months ago

0.0.252

4 months ago

0.0.251

4 months ago

0.0.250

4 months ago

0.0.248

4 months ago

0.0.247

4 months ago

0.0.246

4 months ago

0.0.245

4 months ago

0.0.244

4 months ago

0.0.243

4 months ago

0.0.242

4 months ago

0.0.241

4 months ago

0.0.240

4 months ago

0.0.239

4 months ago

0.0.238

4 months ago

0.0.237

4 months ago

0.0.236

4 months ago

0.0.235

4 months ago

0.0.234

4 months ago

0.0.233

4 months ago

0.0.232

4 months ago

0.0.231

4 months ago

0.0.230

4 months ago

0.0.229

4 months ago

0.0.228

4 months ago

0.0.227

4 months ago

0.0.226

4 months ago

0.0.225

4 months ago

0.0.224

4 months ago

0.0.223

4 months ago

0.0.222

4 months ago

0.0.221

4 months ago

0.0.220

4 months ago

0.0.219

4 months ago

0.0.218

4 months ago

0.0.217

4 months ago

0.0.216

4 months ago

0.0.215

4 months ago

0.0.214

4 months ago

0.0.213

4 months ago

0.0.212

4 months ago

0.0.211

4 months ago

0.0.210

4 months ago

0.0.209

4 months ago

0.0.208

4 months ago

0.0.207

4 months ago

0.0.206

4 months ago

0.0.205

4 months ago

0.0.204

4 months ago

0.0.203

4 months ago

0.0.202

4 months ago

0.0.201

4 months ago

0.0.200

4 months ago

0.0.199

4 months ago

0.0.198

4 months ago

0.0.197

4 months ago

0.0.196

4 months ago

0.0.195

4 months ago

0.0.194

4 months ago

0.0.193

4 months ago

0.0.192

4 months ago

0.0.191

4 months ago

0.0.190

4 months ago

0.0.189

4 months ago

0.0.188

4 months ago

0.0.187

4 months ago

0.0.186

4 months ago

0.0.185

4 months ago

0.0.184

4 months ago

0.0.183

4 months ago

0.0.182

4 months ago

0.0.181

4 months ago

0.0.180

4 months ago

0.0.179

4 months ago

0.0.178

4 months ago

0.0.177

4 months ago

0.0.176

4 months ago

0.0.175

4 months ago

0.0.174

4 months ago

0.0.173

4 months ago

0.0.172

4 months ago

0.0.171

4 months ago

0.0.170

4 months ago

0.0.169

4 months ago

0.0.168

4 months ago

0.0.165

5 months ago

0.0.164

5 months ago

0.0.163

5 months ago

0.0.162

5 months ago

0.0.161

5 months ago

0.0.160

5 months ago

0.0.159

5 months ago

0.0.157

5 months ago

0.0.156

5 months ago

0.0.155

5 months ago

0.0.154

5 months ago

0.0.153

5 months ago

0.0.152

5 months ago

0.0.151

5 months ago

0.0.150

5 months ago

0.0.149

5 months ago

0.0.147

5 months ago

0.0.146

5 months ago

0.0.145

5 months ago

0.0.144

5 months ago

0.0.143

5 months ago

0.0.142

5 months ago

0.0.141

5 months ago

0.0.140

5 months ago

0.0.138

5 months ago

0.0.137

5 months ago

0.0.136

5 months ago

0.0.135

5 months ago

0.0.134

5 months ago

0.0.133

5 months ago

0.0.132

5 months ago

0.0.131

5 months ago

0.0.130

5 months ago

0.0.129

5 months ago

0.0.128

5 months ago

0.0.127

5 months ago

0.0.126

5 months ago

0.0.125

5 months ago

0.0.124

5 months ago

0.0.123

5 months ago

0.0.122

5 months ago

0.0.121

5 months ago

0.0.120

5 months ago

0.0.119

5 months ago

0.0.118

5 months ago

0.0.117

5 months ago

0.0.116

5 months ago

0.0.115

5 months ago

0.0.114

5 months ago

0.0.113

5 months ago

0.0.112

5 months ago

0.0.111

5 months ago

0.0.110

5 months ago

0.0.109

5 months ago

0.0.108

5 months ago

0.0.107

5 months ago

0.0.106

5 months ago

0.0.105

5 months ago

0.0.104

5 months ago

0.0.103

5 months ago

0.0.102

5 months ago

0.0.101

5 months ago

0.0.100

5 months ago

0.0.99

5 months ago

0.0.98

5 months ago

0.0.97

5 months ago

0.0.96

5 months ago

0.0.95

5 months ago

0.0.94

5 months ago

0.0.93

5 months ago

0.0.92

5 months ago

0.0.91

5 months ago

0.0.90

5 months ago

0.0.89

5 months ago

0.0.88

5 months ago

0.0.87

5 months ago

0.0.86

5 months ago

0.0.85

5 months ago

0.0.84

5 months ago

0.0.83

5 months ago

0.0.82

5 months ago

0.0.81

5 months ago

0.0.80

5 months ago

0.0.79

5 months ago

0.0.78

5 months ago

0.0.77

5 months ago

0.0.76

5 months ago

0.0.74

5 months ago

0.0.72

5 months ago

0.0.71

5 months ago

0.0.70

5 months ago

0.0.69

5 months ago

0.0.68

5 months ago

0.0.67

5 months ago

0.0.66

5 months ago

0.0.65

5 months ago

0.0.64

5 months ago

0.0.63

5 months ago

0.0.62

5 months ago

0.0.61

5 months ago

0.0.60

5 months ago

0.0.59

5 months ago

0.0.58

5 months ago

0.0.57

5 months ago

0.0.56

5 months ago

0.0.55

5 months ago

0.0.54

5 months ago

0.0.50

5 months ago

0.0.49

5 months ago

0.0.48

5 months ago

0.0.47

5 months ago

0.0.46

5 months ago

0.0.45

5 months ago

0.0.44

5 months ago

0.0.43

5 months ago

0.0.42

5 months ago

0.0.41

5 months ago

0.0.40

5 months ago

0.0.39

5 months ago

0.0.38

5 months ago

0.0.36

5 months ago

0.0.35

5 months ago

0.0.34

5 months ago

0.0.33

5 months ago

0.0.32

5 months ago

0.0.31

5 months ago

0.0.30

5 months ago

0.0.29

5 months ago

0.0.27

5 months ago

0.0.26

5 months ago

0.0.25

5 months ago

0.0.24

5 months ago

0.0.22

5 months ago

0.0.21

5 months ago

0.0.20

5 months ago

0.0.19

5 months ago

0.0.18

5 months ago

0.0.17

5 months ago

0.0.16

5 months ago

0.0.15

5 months ago

0.0.14

5 months ago

0.0.13

5 months ago

0.0.12

5 months ago

0.0.11

5 months ago

0.0.10

5 months ago

0.0.9

5 months ago

0.0.8

5 months ago

0.0.7

5 months ago

0.0.6

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.1

5 months ago

0.0.0

5 months ago