Live Preview
The live preview is one of Craft's most powerful features. It shows your application exactly as users will see it, updating in real-time as you make changes.
How Live Preview Works#
When you make changes in Craft, the preview:
- Receives the updated code
- Hot-reloads the affected components
- Maintains application state when possible
- Shows you the result instantly
No manual refresh needed!
Using the Preview#
Preview Panel#
The preview panel is located on the right side of the interface. You can:
- Resize by dragging the divider
- Refresh with the refresh button
- Open in new tab for full-screen testing
- Copy link to share with others
Device Modes#
Test on different screen sizes:
| Mode | Width | Use Case | | ------- | ------ | ------------------ | | Mobile | 375px | Phone layouts | | Tablet | 768px | iPad and similar | | Desktop | 1280px | Standard monitors | | Full | 100% | Responsive testing |
Click the device icons or use keyboard shortcuts:
⌘ + 1- Mobile⌘ + 2- Tablet⌘ + 3- Desktop⌘ + 4- Full width
Real-Time Updates#
What Updates Instantly#
- Component changes
- Style modifications
- New pages and routes
- API route updates
- Configuration changes
What Requires Refresh#
- Environment variable changes
- Package installations
- Major structural changes
The preview will indicate when a refresh is needed.
Interacting with the Preview#
The preview is fully interactive:
- Click buttons and links
- Fill out forms
- Navigate between pages
- Test hover states
- Trigger animations
Testing Forms#
Forms in the preview work just like production:
- Fill in fields
- See validation in action
- Submit and check responses
- Verify error handling
Testing Navigation#
Click links to navigate:
- Internal links work normally
- External links open in new tabs
- API calls go to your routes
Sharing Previews#
Share Link#
Get a temporary link to share:
- Click "Share" button
- Copy the generated URL
- Share with stakeholders
Note: Share links expire after 24 hours
Embed Preview#
Embed in documentation or presentations:
<iframe
src="https://preview.craft.fast/your-project-id"
width="100%"
height="600"
></iframe>
Preview vs Production#
The preview environment is similar to production but with some differences:
| Feature | Preview | Production | | ------------- | ---------------- | ---------- | | Performance | Development mode | Optimized | | Caching | Disabled | Enabled | | Error Details | Verbose | Minimal | | Hot Reload | Yes | No |
Troubleshooting#
Preview Not Loading#
- Check your internet connection
- Clear browser cache
- Try refreshing the preview
- Check for JavaScript errors in console
Preview Out of Sync#
If the preview doesn't match your code:
- Click the refresh button
- Wait for changes to apply
- Check for save errors
Slow Preview#
Performance tips:
- Close unused browser tabs
- Use Chrome for best performance
- Disable browser extensions
- Check for infinite loops in code
Console Errors#
Open browser DevTools (F12) to see:
- JavaScript errors
- Network requests
- Console logs
- React component tree
Best Practices#
Test Responsively#
Always check your app on multiple device sizes:
- Start with mobile design
- Scale up to tablet
- Verify desktop layout
- Test edge cases (very wide/narrow)
Test Interactions#
Verify all interactive elements:
- Buttons trigger correct actions
- Forms validate properly
- Navigation works as expected
- Loading states display correctly
Test Edge Cases#
Check unusual scenarios:
- Empty states
- Long text content
- Many items in lists
- Slow network conditions
Next Steps#
- File Management - Organize your project
- Deployment - Go live with your app
- Best Practices - Build better applications