Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to set up a frontend dev environment in Replit

Replit supports frontend development with React, Vite, and Tailwind CSS out of the box. Start a new project by telling Agent to build a React app with Tailwind, or use a React template. Configure hot reload and live preview through the .replit file, set up port forwarding so the preview pane loads automatically, and customize the workspace with pane splitting, themes, and hidden files for a clean coding experience.

What you'll learn

  • Create a React + Vite + Tailwind CSS project in Replit
  • Configure the .replit file for frontend development with hot reload
  • Set up port forwarding and live preview in the workspace
  • Customize the editor layout for efficient frontend workflows
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate8 min read20 minutesAll Replit plans (Starter, Core, Pro, Enterprise)March 2026RapidDev Engineering Team
TL;DR

Replit supports frontend development with React, Vite, and Tailwind CSS out of the box. Start a new project by telling Agent to build a React app with Tailwind, or use a React template. Configure hot reload and live preview through the .replit file, set up port forwarding so the preview pane loads automatically, and customize the workspace with pane splitting, themes, and hidden files for a clean coding experience.

Setting Up a Complete Frontend Development Environment in Replit

Replit can serve as a fully functional frontend development environment with live preview, hot module replacement, and modern tooling like Vite and Tailwind CSS. This tutorial walks through creating a React project, configuring the .replit file for proper dev server behavior, enabling live preview with hot reload, and organizing your workspace for productive frontend work. Whether you start from a template or let Agent scaffold the project, the configuration principles are the same.

Prerequisites

  • A Replit account (Core or Pro recommended for faster builds)
  • Basic familiarity with React and component-based development
  • Understanding of what npm and package.json do
  • A modern browser with JavaScript enabled

Step-by-step guide

1

Create a new React project using Agent or templates

Click the Create App button on the Replit dashboard. You have two options. First, you can describe your project to Agent in natural language, such as 'Create a React app with Tailwind CSS and a landing page.' Agent sets up the project structure, installs dependencies, and configures everything automatically. Second, you can search for a React or Vite template to start with a preconfigured boilerplate. The default and best-supported frontend stack on Replit is React with Tailwind CSS and ShadCN UI. Agent produces the most reliable results with this combination.

Expected result: A new project appears with a React file structure including src/App.jsx or App.tsx, package.json with Vite and React dependencies, and a tailwind.config.js file.

2

Configure the .replit file for Vite dev server

Open the .replit file by enabling Show hidden files from the three-dot menu in the file tree. The .replit file uses TOML format and controls how your app runs. Set the run command to start the Vite development server. Configure the port mapping so Replit knows which local port to expose in the preview pane. Vite defaults to port 5173 but you can set it to any port. The externalPort must be 80 for the preview to work correctly.

typescript
1entrypoint = "src/main.tsx"
2
3run = "npm run dev"
4
5[nix]
6channel = "stable-24_05"
7packages = ["nodejs-20_x"]
8
9[[ports]]
10localPort = 5173
11externalPort = 80
12
13[deployment]
14run = ["npm", "run", "start"]
15build = ["npm", "run", "build"]

Expected result: The .replit file is saved and your project runs the Vite dev server when you click the Run button.

3

Set up Tailwind CSS with the Vite project

If Agent did not already configure Tailwind, install it manually from the Shell. Run the install command for Tailwind and its peer dependencies, then initialize the configuration files. Update the tailwind.config.js content paths to point to your source files. Add the Tailwind directives to your main CSS file. Vite handles PostCSS processing automatically, so Tailwind utility classes work immediately after this setup.

typescript
1npm install -D tailwindcss @tailwindcss/vite

Expected result: Tailwind utility classes like bg-blue-500 and text-white render correctly in the preview pane.

4

Enable hot module replacement for instant feedback

Vite includes hot module replacement by default, which updates the browser preview without a full page reload when you save a file. In Replit, this works through the preview pane's WebSocket connection to the Vite dev server. Make sure your package.json dev script includes the --host flag so Vite binds to 0.0.0.0 instead of localhost. Without this flag, the preview pane may not connect to the dev server properly. Edit the scripts section of package.json to add the flag.

typescript
1{
2 "scripts": {
3 "dev": "vite --host 0.0.0.0",
4 "build": "vite build",
5 "preview": "vite preview --host 0.0.0.0"
6 }
7}

Expected result: When you edit and save a React component, the change appears in the preview pane within one to two seconds without a full page reload.

5

Organize the workspace layout for frontend development

Replit lets you arrange panes to create an efficient layout. A productive frontend setup uses three panes: the file tree and code editor on the left, the preview pane on the right showing your running app, and a Shell or Console pane at the bottom. Split panes by clicking the three-dot menu on any tab and selecting Split Right or Split Down. Drag tabs between panes to rearrange them. Toggle the file tree with the folder icon on the left sidebar. Hide generated files like node_modules and package-lock.json by adding them to the hidden array in your .replit file.

typescript
1# Add to .replit to hide clutter from the file tree
2hidden = [".config", "node_modules", "package-lock.json", "dist"]

Expected result: Your workspace shows code on the left, live preview on the right, and Shell at the bottom, with generated files hidden from the file tree.

6

Install and configure ShadCN UI components

ShadCN UI is the recommended component library on Replit because Agent understands it best. Install it through the Shell using the shadcn CLI. The init command sets up the components.json configuration, installs required dependencies, and creates the component directory structure. After initialization, add individual components as needed. Each component is copied into your source code rather than imported from node_modules, giving you full control to customize them.

typescript
1# Initialize shadcn/ui in your project
2npx shadcn@latest init
3
4# Add specific components
5npx shadcn@latest add button
6npx shadcn@latest add card
7npx shadcn@latest add input

Expected result: ShadCN UI components are installed in your src/components/ui directory and can be imported into any React component.

Complete working example

src/App.tsx
1import { useState } from 'react';
2import { Button } from '@/components/ui/button';
3import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
4import { Input } from '@/components/ui/input';
5
6function App() {
7 const [tasks, setTasks] = useState<string[]>([]);
8 const [newTask, setNewTask] = useState('');
9
10 const addTask = () => {
11 if (newTask.trim()) {
12 setTasks([...tasks, newTask.trim()]);
13 setNewTask('');
14 }
15 };
16
17 const removeTask = (index: number) => {
18 setTasks(tasks.filter((_, i) => i !== index));
19 };
20
21 return (
22 <div className="min-h-screen bg-gray-50 flex items-center justify-center p-4">
23 <Card className="w-full max-w-md">
24 <CardHeader>
25 <CardTitle className="text-2xl font-bold text-center">
26 Task Manager
27 </CardTitle>
28 </CardHeader>
29 <CardContent className="space-y-4">
30 <div className="flex gap-2">
31 <Input
32 value={newTask}
33 onChange={(e) => setNewTask(e.target.value)}
34 onKeyDown={(e) => e.key === 'Enter' && addTask()}
35 placeholder="Add a new task..."
36 />
37 <Button onClick={addTask}>Add</Button>
38 </div>
39 <ul className="space-y-2">
40 {tasks.map((task, index) => (
41 <li
42 key={index}
43 className="flex justify-between items-center p-3 bg-white rounded-lg border"
44 >
45 <span className="text-gray-700">{task}</span>
46 <Button
47 variant="ghost"
48 size="sm"
49 onClick={() => removeTask(index)}
50 className="text-red-500 hover:text-red-700"
51 >
52 Remove
53 </Button>
54 </li>
55 ))}
56 </ul>
57 {tasks.length === 0 && (
58 <p className="text-center text-gray-400 py-4">
59 No tasks yet. Add one above.
60 </p>
61 )}
62 </CardContent>
63 </Card>
64 </div>
65 );
66}
67
68export default App;

Common mistakes when setting up a frontend dev environment in Replit

Why it's a problem: Not adding --host 0.0.0.0 to the Vite dev script

How to avoid: Without the --host flag, Vite binds to localhost which the Replit preview pane cannot reach. Add --host 0.0.0.0 to the dev script in package.json.

Why it's a problem: Setting the wrong externalPort in the .replit file

How to avoid: The externalPort must be 80 for the preview pane to load your app. The localPort should match whatever port your dev server uses (5173 for Vite by default).

Why it's a problem: Installing Tailwind but forgetting to add the directives to the CSS file

How to avoid: Add @import 'tailwindcss' to your main CSS file (usually src/index.css). Without these directives, Tailwind classes will not generate any styles.

Why it's a problem: Using Create React App instead of Vite

How to avoid: Create React App is deprecated and not well supported on Replit. Use Vite for faster builds, better hot reload, and compatibility with the Replit development environment.

Best practices

  • Use the React + Tailwind + ShadCN UI stack for the most reliable Agent results on Replit
  • Always add the --host 0.0.0.0 flag to your Vite dev script so the preview pane connects properly
  • Set externalPort to 80 in your .replit port configuration for the preview to load automatically
  • Hide generated files like node_modules and dist in the .replit hidden array to keep the file tree clean
  • Split the workspace into code, preview, and terminal panes for an efficient development layout
  • Use Agent Lite mode for small visual tweaks to save credits compared to full Autonomous mode
  • Test responsive designs by resizing the preview pane rather than opening a separate browser tab
  • Commit your .replit and tailwind.config.js files to Git so collaborators get the same environment

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to set up a React project with Vite, Tailwind CSS, and ShadCN UI on Replit. Walk me through the .replit configuration, port forwarding, and workspace layout for an efficient frontend development experience.

Replit Prompt

Create a React app with Vite, Tailwind CSS, and ShadCN UI. Configure the .replit file with the correct port mapping for live preview. Set up hot module replacement so changes appear instantly in the preview pane. Hide node_modules and dist from the file tree.

Frequently asked questions

Yes. Replit supports any frontend framework. However, React with Tailwind CSS and ShadCN UI is the default and best-supported stack. Agent produces the most reliable results with this combination.

The most common cause is a port mismatch. Check that your localPort in .replit matches the port your dev server uses, and that externalPort is set to 80. Also verify your dev script includes --host 0.0.0.0.

Yes. Hot module replacement works on all Replit plans. However, the free tier has limited CPU and RAM, so builds and reloads may be slower compared to Core or Pro plans.

Import fonts from Google Fonts or another CDN in your index.html file, or install them as npm packages. Reference the font family in your Tailwind configuration under theme.extend.fontFamily.

Yes. Vite supports TypeScript out of the box. Rename your files from .jsx to .tsx and .js to .ts. Install type definitions for React with npm install -D @types/react @types/react-dom.

The development preview URL is accessible while your app is running, but it is not a permanent public URL. For a stable URL, deploy your app using Replit Deployments, which gives you a persistent .replit.app subdomain.

Open DevTools in the preview pane by right-clicking and selecting Inspect. This gives you the same element inspector, console, and network tab you would have in a regular browser. Client-side console.log output appears here, not in the Replit Console.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.