A step-by-step guide to running Gemini-generated React code locally.
- Node.js and npm installed on your system
- Basic knowledge of React and command line operations
-
Create a new Vite project:
npm create vite@latest my-app
-
When prompted, select:
- Framework: React
- Variant: JavaScript
-
Navigate to the project folder:
cd my-app -
Install dependencies:
npm install
-
Install Tailwind CSS and its dependencies:
npm install -D tailwindcss postcss autoprefixer
-
Initialize Tailwind CSS:
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/**/*"] } -
Initialize Shadcn UI:
npx shadcn-ui@latest init
When prompted, select the following options:
✔ 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
-
Install required Shadcn UI components:
npx shadcn-ui@latest add card button input
-
Install Lucide React:
npm install lucide-react
-
Create a new file for your component:
touch src/components/LLMModel.jsx
-
Paste your Gemini-generated React code into
src/components/LLMModel.jsx. -
Update
src/App.jsx:import './App.css' import LLMModel from './components/LLMModel' function App() { return ( <> <LLMModel/> </> ) } export default App
Start the development server:
npm run devYour Gemini-generated React component should now be running locally! Open your browser and navigate to the URL provided in the terminal (usually http://localhost:5173).