Learn how to customize the Pika Framework user interface, configure features, and extend functionality using designated customization areas that are protected from framework updates.
What You'll Accomplish
Section titled “What You'll Accomplish”By the end of this guide, you will:
- Configure project names and branding
- Customize site-wide features
- Configure home page experience
- Add custom message tag renderers
- Implement custom authentication
- Understand protected customization areas
- Manage sync configuration
Prerequisites
Section titled “Prerequisites”- A running Pika installation
- Access to project configuration files
- Understanding of SvelteKit and TypeScript (for advanced customization)
- Familiarity with AWS CDK (for infrastructure changes)
Understanding Customization Areas
Section titled “Understanding Customization Areas”Pika Framework provides designated areas where you can add custom code without worrying about framework updates overwriting your changes. These areas are protected from sync operations.
Step 1: Configure Project Names and Branding
Section titled “Step 1: Configure Project Names and Branding”All customization starts with configuring your project identity.
Central Configuration
Section titled “Central Configuration”Location: pika-config.ts (root directory)
This file is the single source of truth for project names and is protected from framework updates.
export const pikaConfig: PikaConfig = { pika: { projNameL: 'mycompany', // All lowercase projNameKebabCase: 'mycompany', // Kebab case projNameTitleCase: 'MyCompany', // Title case projNameCamel: 'mycompany', // Camel case projNameHuman: 'My Company' // Human readable }, pikaChat: { projNameL: 'mycompanychat', // All lowercase projNameKebabCase: 'mycompany-chat', // Kebab case projNameTitleCase: 'MyCompanyChat', // Title case projNameCamel: 'myCompanyChat', // Camel case projNameHuman: 'My Company Chat' // Human readable }};Why This Matters:
- All AWS resources use these names
- Stack definitions automatically import these values
- Ensures consistent naming across your infrastructure
Step 2: Customize Home Page
Section titled “Step 2: Customize Home Page”Configure the home page title, welcome message, and chat app link visibility.
Location: pika-config.ts (root directory)
export const pikaConfig: PikaConfig = { // ... project names configuration siteFeatures: { homePage: { // Custom title homePageTitle: 'Welcome to My Company Chat',
// Custom welcome message welcomeMessage: 'Get started by selecting a chat app below or asking me anything!',
// Configure which users see links to which chat apps linksToChatApps: { userChatAppRules: [ // External users see only external chat apps { userTypes: ['external-user'], chatAppUserTypes: ['external-user'] }, // Internal users see all chat apps { userTypes: ['internal-user'], chatAppUserTypes: ['internal-user', 'external-user'] } ] } } }};Configuration Options:
| Option | Description | Required |
|---|---|---|
homePageTitle | Custom title for home page | No |
welcomeMessage | Custom welcome message | No |
linksToChatApps | Rules for showing chat app links | No |
Chat App Link Rules
Section titled “Chat App Link Rules”Control which users see which chat apps on the home page:
- System checks user's user type
- Finds matching rules in
userChatAppRules - Shows chat apps whose user types match
chatAppUserTypes - If no rules match, no chat app links appear
Step 3: Configure Site Features
Section titled “Step 3: Configure Site Features”Configure features that affect the entire application.
Location: pika-config.ts (root directory)
Intelligence Features
Section titled “Intelligence Features”siteFeatures: { // Show AI reasoning traces traces: { featureId: 'traces', enabled: true, userTypes: ['internal-user'], detailedTraces: { enabled: true, userTypes: ['internal-user'], userRoles: ['pika:content-admin'] } },
// Verify and improve response quality verifyResponse: { featureId: 'verifyResponse', enabled: true, autoRepromptThreshold: 'C', // Auto-improve responses graded C or lower userTypes: ['internal-user', 'external-user'] },
// User memory for context userMemory: { featureId: 'userMemory', enabled: true, strategy: 'semantic', conversationMemoryStrategy: 'preferences' }}UI Features
Section titled “UI Features”siteFeatures: { // Enable logout logout: { featureId: 'logout', enabled: true, userTypes: ['internal-user', 'external-user'] },
// Enable file upload fileUpload: { featureId: 'fileUpload', enabled: true, mimeTypesAllowed: [ 'image/*', 'application/pdf', 'text/plain', '.docx', '.xlsx' ] },
// Chat suggestions suggestions: { featureId: 'suggestions', enabled: true, suggestions: [], // Chat apps define their own maxToShow: 5, randomize: false },
// Input field label promptInputFieldLabel: { featureId: 'promptInputFieldLabel', enabled: true, promptInputFieldLabel: 'Ready to chat' },
// UI customization uiCustomization: { featureId: 'uiCustomization', enabled: true, showUserRegionInLeftNav: false, showChatHistoryInStandaloneMode: true },
// Disclaimer notice chatDisclaimerNotice: { featureId: 'chatDisclaimerNotice', enabled: true, notice: 'This AI-powered chat is here to help, but it may not always be accurate. For urgent issues, please contact support.' }}Access Control Features
Section titled “Access Control Features”siteFeatures: { // Site admin interface siteAdmin: { websiteEnabled: true // Users need 'pika:site-admin' role },
// Content admin access contentAdmin: { enabled: true // Users need 'pika:content-admin' role },
// Entity-based access entity: { enabled: true, attributeName: 'accountId', searchPlaceholderText: 'Search for an account...', displayNameSingular: 'Account', displayNamePlural: 'Accounts' }}Step 4: Add Custom Message Tag Renderers
Section titled “Step 4: Add Custom Message Tag Renderers”Create custom renderers for XML tags in LLM responses.
Location: apps/pika-chat/src/lib/client/features/chat/message-segments/custom-components/
Create Custom Renderer
Section titled “Create Custom Renderer”<script lang="ts"> export let data: { headers: string[]; rows: string[][] };</script>
<div class="custom-table"> <table> <thead> <tr> {#each data.headers as header} <th>{header}</th> {/each} </tr> </thead> <tbody> {#each data.rows as row} <tr> {#each row as cell} <td>{cell}</td> {/each} </tr> {/each} </tbody> </table></div>
<style> .custom-table { overflow-x: auto; } table { width: 100%; border-collapse: collapse; } th, td { padding: 0.5rem; border: 1px solid #ddd; text-align: left; } th { background-color: #f5f5f5; font-weight: bold; }</style>Register Renderer
Section titled “Register Renderer”import CustomDataTable from './CustomDataTable.svelte';
export const customRenderers: Record<string, Component<any>> = { 'data-table': CustomDataTable};Usage in LLM Response
Section titled “Usage in LLM Response”<data-table>{ "headers": ["Name", "Age", "City"], "rows": [ ["John", "30", "NYC"], ["Jane", "25", "LA"] ]}</data-table>Step 5: Implement Custom Authentication
Section titled “Step 5: Implement Custom Authentication”Configure custom authentication flows for your SSO or auth provider.
Location: apps/pika-chat/src/lib/server/auth-provider/
import { AuthProvider } from 'pika-shared/types/chatbot/chatbot-types';import type { AuthenticatedUser } from 'pika-shared/types/chatbot/chatbot-types';
export default class CustomAuthProvider extends AuthProvider<YourAuthData, YourCustomData> { async getUser(event: RequestEvent): Promise<AuthenticatedUser | undefined> { // Your authentication logic const token = event.cookies.get('auth_token'); if (!token) return undefined;
const userData = await validateToken(token); if (!userData) return undefined;
return { userId: userData.id, firstName: userData.firstName, lastName: userData.lastName, email: userData.email, userType: userData.isEmployee ? 'internal-user' : 'external-user', roles: this.assignRoles(userData), customData: { accountId: userData.accountId, permissions: userData.permissions } }; }
private assignRoles(userData: any): string[] { const roles: string[] = [];
if (userData.isAdmin) { roles.push('pika:site-admin'); }
if (userData.isSupport) { roles.push('pika:content-admin'); }
return roles; }}Step 6: Add Custom Web Applications
Section titled “Step 6: Add Custom Web Applications”Create new web applications within your Pika project.
Location: apps/custom/
# Create new SvelteKit appcd apps/customnpm create svelte@latest my-admin-panel
# Install dependenciescd my-admin-panelnpm installUse Cases:
- Admin dashboards
- Customer portals
- Internal tools
- Separate applications for different user types
Step 7: Add Custom Services
Section titled “Step 7: Add Custom Services”Create new backend services and API endpoints.
Location: services/custom/
Use Cases:
- Payment processing services
- Email notification services
- Data analytics services
- Third-party integrations
Protected Customization Areas
Section titled “Protected Customization Areas”These areas are never overwritten by framework updates:
- Project Configuration -
pika-config.ts - Custom Message Tag Renderers -
apps/pika-chat/src/lib/client/features/chat/message-segments/custom-components/ - Authentication -
apps/pika-chat/src/lib/server/auth-provider/ - Custom Web Applications -
apps/custom/ - Custom Services -
services/custom/ - Stack Definition Files (by default):
apps/pika-chat/infra/bin/pika-chat.tsservices/pika/bin/pika.ts
Step 8: Configure Sync Settings
Section titled “Step 8: Configure Sync Settings”Control which files are protected from framework updates.
Location: .pika-sync.json (root directory)
{ "userProtectedAreas": [ "my-custom-config.ts", "apps/my-custom-app/" ], "userUnprotectedAreas": [ "apps/pika-chat/infra/bin/pika-chat.ts", "services/pika/bin/pika.ts" ]}Configuration:
userProtectedAreas- Additional files you want to protectuserUnprotectedAreas- Default protected files you want to allow updates for
Feature Configuration Hierarchy
Section titled “Feature Configuration Hierarchy”Features follow this precedence order:
- Site Level (in
pika-config.ts) - Chat App Override (in chat app definition)
- Admin Override (via Site Admin interface)
Rules:
- Site-level settings are the baseline
- Chat apps can make features more restrictive
- Admin overrides completely replace chat app settings
- No level can enable site-disabled features
Best Practices
Section titled “Best Practices”1. Configure Project Names First
Section titled “1. Configure Project Names First”Before customizing anything else, update project names in pika-config.ts. This ensures consistent naming across all AWS resources.
2. Use Designated Areas
Section titled “2. Use Designated Areas”Always place custom code in designated customization areas. Files outside these areas may be overwritten during framework updates.
3. Keep Customizations Focused
Section titled “3. Keep Customizations Focused”Use the appropriate area for your custom code:
| Type | Location |
|---|---|
| Project names | pika-config.ts |
| UI components | Custom Components |
| Auth logic | Custom Authentication |
| New apps | Custom Web Applications |
| Backend services | Custom Services |
| Infrastructure | Stack Definition Files |
4. Version Control
Section titled “4. Version Control”Initialize git and commit customizations regularly:
git initgit add .git commit -m "Initial commit with customizations"5. Test After Updates
Section titled “5. Test After Updates”After running pika sync, always test customizations to ensure they still work correctly.
6. Document Changes
Section titled “6. Document Changes”Keep documentation of customizations, especially for complex changes to stack definitions or custom services.
Framework Updates
Section titled “Framework Updates”When you run pika sync:
- Framework files get latest changes
- All files in protected areas are preserved
- Your
userProtectedAreasmerge with defaults - Files in
userUnprotectedAreascan be updated
This ensures customizations are preserved while receiving framework improvements.
Common Scenarios
Section titled “Common Scenarios”Scenario 1: Corporate Branding
Section titled “Scenario 1: Corporate Branding”// Update project namespikaConfig.pikaChat.projNameHuman = 'Acme Corp Assistant';
// Configure home pagesiteFeatures.homePage = { homePageTitle: 'Acme Corp AI Assistant', welcomeMessage: 'Welcome! How can I help you today?'};
// Add custom CSS in app.css for brand colorsScenario 2: Multi-Tenant SaaS
Section titled “Scenario 2: Multi-Tenant SaaS”// Enable entity featuresiteFeatures.entity = { enabled: true, attributeName: 'companyId', displayNameSingular: 'Company', displayNamePlural: 'Companies'};
// Enable site admin for access controlsiteFeatures.siteAdmin = { websiteEnabled: true};
// Configure access rules per tenant in Site Admin interfaceScenario 3: Internal Tool
Section titled “Scenario 3: Internal Tool”// Restrict to internal userssiteFeatures.logout = { enabled: true, userTypes: ['internal-user']};
// Enable all admin featuressiteFeatures.contentAdmin = { enabled: true };siteFeatures.siteAdmin = { websiteEnabled: true };siteFeatures.traces = { enabled: true, userTypes: ['internal-user']};Next Steps
Section titled “Next Steps”- Integrate Your Authentication System - Implement custom auth
- Use Custom Message Tags - Create custom renderers
- Override Default Features - Per-app customization
- Build Custom Web Components - Create interactive widgets
Related Documentation
Section titled “Related Documentation”- Authentication Guide - Complete auth implementation
- Feature Configuration Reference - All feature options
- Access Control - Access control system