Skip to main content

Basic Usage - v4.0

Installation

npm install @myproject/core@^4.0.0
# or using the new optimized installer
npx @myproject/installer@latest

Quick Start

# Initialize a new project with AI assistance
npx create-myproject@latest my-app --ai-assist

# Start development server with hot reload
npm run dev

# Build for production with optimization
npm run build:optimize

Configuration

// config.ts - Now with TypeScript and validation
import { defineConfig } from '@myproject/core'

export default defineConfig({
version: '4.0',
apiUrl: process.env.API_URL || 'https://api-v4.example.com',
debug: process.env.NODE_ENV !== 'production',

// New in v4.0
ai: {
enabled: true,
model: 'gpt-4',
codeAssist: true
},

performance: {
prefetch: true,
lazyLoad: true,
edgeOptimized: true
},

auth: {
provider: 'oauth2',
clientId: process.env.OAUTH_CLIENT_ID
}
})

API Reference

Core Functions (v4.0)

// Async/await by default
await app.init({
plugins: ['ai-assist', 'edge-cache']
})

// Real-time rendering with React 18
app.render(<App />, {
concurrent: true,
suspense: true
})

// Enhanced data fetching
const data = await app.getData({
cache: 'edge',
revalidate: 60,
transform: 'camelCase'
})

New AI Features

// Generate code from natural language
const code = await ai.generateCode(
"Create a React component that fetches and displays user data"
)

// Smart error suggestions
try {
await riskyOperation()
} catch (error) {
const suggestion = await ai.suggestFix(error)
console.log(suggestion)
}

CLI Commands

# Interactive setup wizard
myproject init

# AI-powered debugging
myproject debug --ai

# Performance analysis
myproject analyze

# Deploy to edge
myproject deploy --edge