Quick Start
Build your first PACE app in 5 minutes.
Prerequisites
- Node.js 18+ (or modern browser for CDN)
- Text editor
- Basic JavaScript knowledge
Step 1: Install PACE.js
Option A: NPM (Recommended)
npm install @semanticintent/pace-patternOption B: CDN
<script type="module">
import { PACE } from 'https://cdn.jsdelivr.net/npm/@semanticintent/pace-pattern/dist/pace.esm.js'
</script>Step 2: Create Your Project
Create these files:
my-pace-app/
├── index.html
├── app.js
└── products.jsonindex.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My PACE App</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@semanticintent/pace-pattern/dist/pace.min.css">
</head>
<body>
<div id="app"></div>
<script type="module" src="app.js"></script>
</body>
</html>app.js
import { PACE } from '@semanticintent/pace-pattern'
const pace = new PACE({
container: '#app',
products: './products.json',
greeting: 'Welcome! What can I help you find?'
})
pace.mount()products.json
{
"products": [
{
"id": "product-1",
"name": "Starter Kit",
"tagline": "Everything you need to get started",
"category": "Getting Started",
"description": "## Starter Kit\n\nPerfect for beginners. Includes all the basics.",
"action_label": "Get Started",
"action_url": "https://example.com/starter"
},
{
"id": "product-2",
"name": "Pro Tools",
"tagline": "Advanced features for power users",
"category": "Advanced",
"description": "## Pro Tools\n\nFor experienced users who need more control.",
"action_label": "Learn More",
"action_url": "https://example.com/pro"
},
{
"id": "product-3",
"name": "Enterprise Suite",
"tagline": "Full-featured solution for teams",
"category": "Enterprise",
"description": "## Enterprise Suite\n\nComplete solution with team collaboration.",
"action_label": "Contact Sales",
"action_url": "https://example.com/enterprise"
}
]
}Step 3: Run Your App
With NPM
npm install -g serve
serve .With Python
python -m http.server 8000With Node.js
npx http-serverOpen http://localhost:8000 in your browser.
Step 4: See It Work
You should see:
- Purple gradient interface with sidebar navigation
- Product catalog showing 3 products grouped by category
- About page with default PACE information
- Chat widget (without AI, shows placeholder)
- Executive Summary tracking your activity
Try These Actions
✅ Click a product — See it highlighted ✅ Search products — Type "pro" in search box ✅ Navigate — Click sidebar items (Product, About, Chat, Summary) ✅ Check URL — Notice hash-based routing (#product, #about, etc.)
Step 5: Add AI (Optional)
To enable the conversational guide, add an AI adapter:
Using Claude
import { PACE, ClaudeAdapter } from '@semanticintent/pace-pattern'
const pace = new PACE({
container: '#app',
products: './products.json',
aiAdapter: new ClaudeAdapter({
apiKey: 'YOUR_ANTHROPIC_API_KEY',
model: 'claude-3-sonnet-20240229'
}),
greeting: 'Welcome! What are you fishing for?'
})
pace.mount()Using OpenAI
import { PACE, OpenAIAdapter } from '@semanticintent/pace-pattern'
const pace = new PACE({
container: '#app',
products: './products.json',
aiAdapter: new OpenAIAdapter({
apiKey: 'YOUR_OPENAI_API_KEY',
model: 'gpt-4'
})
})
pace.mount()API Keys
Never commit API keys to version control. Use environment variables:
apiKey: process.env.CLAUDE_API_KEYStep 6: Customize
Change Colors
const pace = new PACE({
container: '#app',
products: './products.json',
theme: {
primary: '#3b82f6', // Blue
accent: '#8b5cf6', // Purple
font: 'Roboto, sans-serif'
}
})Change Greeting
const pace = new PACE({
container: '#app',
products: './products.json',
greeting: 'Hi there! Looking for something specific?'
})Set Default View
const pace = new PACE({
container: '#app',
products: './products.json',
defaultView: 'chat' // Start on chat instead of products
})Troubleshooting
"Cannot find module"
Problem: Import error when using NPM.
Solution:
rm -rf node_modules package-lock.json
npm install"PACE is not defined"
Problem: Using UMD build incorrectly.
Solution: Access via namespace:
const pace = new PACE.PACE({ ... })Or use ESM:
import { PACE } from '@semanticintent/pace-pattern'Products not loading
Problem: CORS error loading products.json.
Solution: Use a local server (see Step 3), not file:// protocol.
Styles not applied
Problem: CSS not loading.
Solution: Add stylesheet:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@semanticintent/pace-pattern/dist/pace.min.css">Next Steps
Congratulations! You've built your first PACE app. 🎉
What's next?
Continue Learning
- Build Your First App — Step-by-step tutorial with explanations
- Customize Themes — Make it yours with custom styling
- Add AI Adapters — Enable conversational guidance
- Core Concepts — Understand how PACE.js works
Full Example
Here's everything in one file for easy copy-paste:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My PACE App</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@semanticintent/pace-pattern/dist/pace.min.css">
</head>
<body>
<div id="app"></div>
<script type="module">
import { PACE } from 'https://cdn.jsdelivr.net/npm/@semanticintent/pace-pattern/dist/pace.esm.js'
const pace = new PACE({
container: '#app',
products: {
products: [
{
id: '1',
name: 'Starter Kit',
tagline: 'Everything you need to get started',
category: 'Getting Started',
description: '## Starter Kit\n\nPerfect for beginners.',
action_label: 'Get Started',
action_url: 'https://example.com'
},
{
id: '2',
name: 'Pro Tools',
tagline: 'Advanced features',
category: 'Advanced',
description: '## Pro Tools\n\nFor power users.',
action_label: 'Learn More',
action_url: 'https://example.com'
}
]
},
greeting: 'Welcome! What can I help you find?'
})
pace.mount()
// Listen to events
pace.on('ready', () => {
console.log('PACE is ready!')
})
pace.on('product:select', ({ product }) => {
console.log('Selected:', product.name)
})
</script>
</body>
</html>Save this as index.html, run a local server, and you're done!
Built your first PACE app in 5 minutes! 🚀