Knowing the project structure helps you find and organize your files easily. It makes building and maintaining your app simpler.
Project structure overview in Remix
my-remix-app/ ├── app/ │ ├── routes/ │ ├── components/ │ ├── styles/ │ ├── entry.client.tsx │ ├── entry.server.tsx │ └── root.tsx ├── public/ ├── remix.config.js ├── package.json └── tsconfig.json
The app/ folder holds most of your code like pages and components.
The routes/ folder inside app/ maps URLs to files automatically.
/.app/routes/index.tsx
app/components/NavBar.tsx
public/favicon.ico
This is a simple homepage component inside app/routes/index.tsx. It uses a loader to fetch data and displays a welcome message.
import type { LoaderFunction } from '@remix-run/node'; import { json } from '@remix-run/node'; import { useLoaderData } from '@remix-run/react'; export const loader: LoaderFunction = async () => { return json({ message: 'Welcome to Remix!' }); }; export default function Index() { const data = useLoaderData<typeof loader>(); return ( <main> <h1>{data.message}</h1> <p>This is the homepage from <code>app/routes/index.tsx</code>.</p> </main> ); }
Files inside app/routes/ automatically become pages based on their file name and folder.
Use public/ for images, fonts, and other static assets accessible by URL.
Keep components in app/components/ to reuse UI parts easily.
Remix projects have a clear folder structure to organize code and assets.
app/routes/ controls your app's pages and URLs.
Understanding this structure helps you build and maintain Remix apps smoothly.
Practice
Solution
Step 1: Understand Remix folder roles
Theapp/routes/folder is where you put files that map to pages and URLs in Remix. Since pages and URLs are controlled by route files,app/routes/is the correct folder.Final Answer:
app/routes/ -> Option AQuick Check:
Pages and URLs = app/routes/ [OK]
- Confusing public folder with routes
- Thinking components folder controls URLs
- Mixing styles folder with routing
Solution
Step 1: Identify where static files go
Static assets like images should be accessible directly by the browser, so they go in thepublic/folder. Thepublic/folder is served as-is, making it the right place for images and other static files.Final Answer:
public/ -> Option BQuick Check:
Static assets = public folder [OK]
- Putting images inside routes folder
- Confusing assets folder with public
- Placing static files inside styles folder
app/
routes/
index.tsx
about.tsx
components/
Header.tsx
styles/
global.css
public/
logo.pngWhich file controls the home page content?
Solution
Step 1: Understand home page routing in Remix
The home page is controlled by theindex.tsxfile insideapp/routes/.app/routes/index.tsxdefines the root URL page, so it controls the home page content.Final Answer:
app/routes/index.tsx -> Option DQuick Check:
Home page = routes/index.tsx [OK]
- Choosing component files for page content
- Confusing public files with pages
- Picking styles files as page controllers
app/components/ instead of app/routes/. What will happen when you try to visit that page URL?Solution
Step 1: Understand routing folder role
Only files insideapp/routes/define pages and URLs in Remix. Files inapp/components/are not routes, so the URL won't find the page and returns 404.Final Answer:
404 Not Found error -> Option AQuick Check:
Page file outside routes = 404 error [OK]
- Expecting page to load from components folder
- Thinking app crashes on wrong folder
- Assuming styles affect routing errors
/contact. Which is the correct way to add this page in your Remix project structure?Solution
Step 1: Know how to add new pages in Remix
New pages are added by creating files insideapp/routes/matching the URL path. For URL/contact, createapp/routes/contact.tsxwith the page component.Final Answer:
Create app/routes/contact.tsx with page component -> Option CQuick Check:
New page URL = new file in routes folder [OK]
- Adding page files in components folder
- Placing HTML files in public for pages
- Only adding CSS without page component
Ready to prove it?
Pass the test and this pattern moves unknown
