Claude recently released Artifacts, which can compile code in a dedicated window. This tutorial helps beginners set up a React app to any React run code generated by Claude's Artifacts feature.
Claude-React-Jumpstart: A step-by-step guide to running Claude-generated React code locally.
You can use the example provided to learn the process. Before beginning the following steps, remove the my-app folder so you can recreate it.
npm create vite@latest my-app
β Select a framework: βΊ React
β Select a variant: βΊ JavaScript
cd my-app
npm install
From instructions: https://ui.shadcn.com/docs/installation/vite
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Update vite.config.js
:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})
Create jsconfig.json
:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"]
}
npx shadcn-ui@latest init
β Would you like to use TypeScript (recommended)? no
β Which style would you like to use? βΊ Default
β Which color would you like to use as base color? βΊ Slate
β Where is your global CSS file? β¦ src/index.css
β Would you like to use CSS variables for colors? β¦ yes
β Are you using a custom tailwind prefix eg. tw-? (Leave blank if not) β¦
β Where is your tailwind.config.js located? β¦ tailwind.config.js
β Configure the import alias for components: β¦ @/components
β Configure the import alias for utils: β¦ @/lib/utils
β Are you using React Server Components? β¦ no
β Write configuration to components.json. Proceed? β¦ yes
Choose your list of required components and libraries to download based upon the imports in your react file.
npx shadcn-ui@latest add card button input
npm install lucide-react
LLMModel.jsx
is an included artifact example. You can move the file to src/components/LLMModel.jsx
.
Then add it to your app by updating App.jsx
:
import './App.css'
import LLMModel from './components/LLMModel'
function App() {
return (
<>
<LLMModel/>
</>
)
}
export default App
npm run dev