Skip to content

Commit 8a541ed

Browse files
drhemaclaude
andcommitted
Show friendly message for non-React frameworks instead of broken Sandpack
Nuxt and Astro can't run in Sandpack (React-only sandbox). Instead of showing a crash, display a message explaining they need the Live preview and provide a "Switch to Live" button. Default to deployed mode for non-React frameworks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dbc06c6 commit 8a541ed

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/components/vibecoder/browser-tab.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface BrowserTabProps {
1111
projectUrl: string
1212
projectId: string
1313
projectStatus: string
14+
framework?: string
1415
generatedFiles?: Record<string, string>
1516
}
1617

@@ -365,9 +366,10 @@ function toSandpackFiles(files: Record<string, string>): { files: Record<string,
365366
return { files: sandpackFiles, template: useTS ? 'react-ts' : 'react' }
366367
}
367368

368-
export function BrowserTab({ projectUrl, projectId, projectStatus, generatedFiles }: BrowserTabProps) {
369+
export function BrowserTab({ projectUrl, projectId, projectStatus, framework, generatedFiles }: BrowserTabProps) {
370+
const isSandpackCompatible = !framework || framework === 'nextjs'
369371
const [viewMode, setViewMode] = useState<ViewMode>('desktop')
370-
const [previewMode, setPreviewMode] = useState<PreviewMode>('sandbox')
372+
const [previewMode, setPreviewMode] = useState<PreviewMode>(isSandpackCompatible ? 'sandbox' : 'deployed')
371373
const [isLoading, setIsLoading] = useState(false)
372374
const [isDeployedLive, setIsDeployedLive] = useState(false)
373375
const [showConsole, setShowConsole] = useState(false)
@@ -602,7 +604,28 @@ export function BrowserTab({ projectUrl, projectId, projectStatus, generatedFile
602604
style={viewMode !== 'desktop' ? { width: VIEW_WIDTHS[viewMode], maxWidth: '100%' } : undefined}
603605
>
604606
{previewMode === 'sandbox' ? (
605-
hasGeneratedCode ? (
607+
!isSandpackCompatible ? (
608+
<div className="h-full flex items-center justify-center text-gray-400">
609+
<div className="text-center px-8 py-12">
610+
<div className="w-16 h-16 rounded-2xl bg-gray-100 dark:bg-gray-800 flex items-center justify-center mx-auto mb-4">
611+
<Globe className="w-8 h-8 text-gray-300 dark:text-gray-600" />
612+
</div>
613+
<p className="text-sm font-semibold text-gray-600 dark:text-gray-300 mb-2">
614+
{framework === 'nuxt' ? 'Nuxt' : framework === 'astro' ? 'Astro' : framework} preview
615+
</p>
616+
<p className="text-xs text-gray-400 dark:text-gray-500 max-w-[280px] leading-relaxed">
617+
Instant sandbox preview is available for Next.js/React projects. For {framework === 'nuxt' ? 'Nuxt' : framework === 'astro' ? 'Astro' : framework} projects, deploy first then use the <strong className="text-gray-500 dark:text-gray-400">Live</strong> tab to preview.
618+
</p>
619+
<button
620+
onClick={() => setPreviewMode('deployed')}
621+
className="mt-4 inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-brand-600 dark:text-brand-400 bg-brand-50 dark:bg-brand-900/20 rounded-lg hover:bg-brand-100 dark:hover:bg-brand-900/30 transition-colors"
622+
>
623+
<Globe className="w-3.5 h-3.5" />
624+
Switch to Live
625+
</button>
626+
</div>
627+
</div>
628+
) : hasGeneratedCode ? (
606629
<div className="h-full w-full flex flex-col">
607630
<SandpackProvider
608631
key={sandpackKey}

src/components/vibecoder/ide-layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export function IdeLayout({ project, onProjectUpdate }: IdeLayoutProps) {
230230
projectUrl={`https://${project.subdomain}`}
231231
projectId={project.id}
232232
projectStatus={project.status}
233+
framework={project.framework}
233234
generatedFiles={generatedFiles}
234235
/>
235236
)}

0 commit comments

Comments
 (0)