react-setup
Skill2 starsChanged 13 months agoApache-2.0View on GitHub
Use when initializing a new React frontend with Vite to connect to a Django backend over HTTPS. Sets up routing, CSRF protection, Axios config, and validates the build. Not for existing React projects.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ghalex/skillstheir own version, first seen Jun 29, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ghalex/skills★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- apply-shadcnSkill
- django-allauthSkill
- django-setupSkill
- react-allauthSkill
- tailwind-setupSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 52
Read existing frontend/vite.config.js (created by Vite)
- Very specific: line 53
Add imports: fs, path
- Distinctive: line 171
Create Navbar and Footer Components
- Very specific: line 222
Import axios from ../services/api, useState, useEffect
- Distinctive: line 233
Add heading + text explaining the backend connectivity check
- Very specific: line 248
Create browser router from createAppRouter() config
- Very specific: line 255
Remove: All useState, demo imports (reactLogo, viteLogo, App.css), counter UI
- Very specific: line 256
Add imports: Router from ./router
- Very specific: line 263
Run npm --prefix ./frontend run build to validate imports, dependencies, and syntax
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
Sets up a production-ready React + Vite frontend configured for Django backend integration with:
- HTTPS local development (using mkcert certificates)
- CSRF token handling for Django session auth
- Axios interceptors for automatic CSRF injection
- React Router with layout structure
- Production build validation
When to use: New React projects that need Django backend connectivity When NOT to use: Existing React projects, non-Django backends, or projects not using session auth
Prerequisites
- Django backend configured with HTTPS
- mkcert certificates in
/certs/directory (usemkcert-https-setupskill) - Node.js 18+ installed
Copy this checklist and track your progress:
- 1. Initialize React + Vite Project
- 2. Configure vite.config.js:
- 3. Create API Configuration
- 4. Create CSRF Service
- 5. Create Axios Configuration
- 6. Create Navbar and Footer Components
- 7. Create
src/layouts/Root.jsx: - 8. Create Page Components
- 9. Create
src/router/AppRoutes.jsx - 10. Create Router Wrapper
- 11. Update App.jsx
- 12. Verify Setup
- Initialize React + Vite Project
npm create vite@latest frontend -- --template react --yesnpm --prefix ./frontend install react-router-dom axios
- Configure vite.config.js:
- List cert files in
certs/to find actual filenames - Read existing
frontend/vite.config.js(created by Vite) - Add imports:
fs,path - Add server config:
- server.https: Load key/cert from
certs/using found filenames - server.port: 5173
- server.proxy:
/api→https://localhost:8000(changeOrigin: true, secure: false)
- server.https: Load key/cert from
- Create API Configuration
src/config/api.js:
export const API_BASE_URL = ''; // Empty string uses Vite proxy
export const ENDPOINTS = {
CSRF: '/api/csrf/',
// Add your API endpoints here as you build features
// Example: PRODUCTS: '/api/products/',
};- Create CSRF Service
src/services/csrf.js:
import { ENDPOINTS } from '../config/api';
let csrfToken = null;
/**
* Fetches and caches the CSRF token from Django backend
* The token is stored in a cookie by Django after the first request
*/
export async function getCsrfToken() {
// Return cached token if available
if (csrfToken) {
return csrfToken;
}
try {
const response = await fetch(ENDPOINTS.CSRF, {
credentials: 'include',
headers: {
'Accept': 'application/json',
}
});
if (!response.ok) {
throw new Error(`Failed to fetch CSRF token: ${response.status}`);
}
// Django sets the token in a cookie after this request
const cookies = document.cookie.split(';');
const csrfCookie = cookies.find(cookie => cookie.trim().startsWith('csrftoken='));
if (!csrfCookie) {
throw new Error('CSRF token not found in cookies');
}
csrfToken = csrfCookie.split('=')[1].trim();
return csrfToken;
} catch (error) {
console.error('CSRF token fetch error:', error);
throw error;
}
}
/**
* Clears the cached CSRF token (useful for logout or token refresh)
*/
export function clearCsrfToken() {
csrfToken = null;
}- Create Axios Configuration
src/services/api.js:
import axios from 'axios';
import { API_BASE_URL } from '../config/api';
import { getCsrfToken } from './csrf'; // ADD THIS
const axiosInstance = axios.create({
baseURL: API_BASE_URL,
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
// REQUEST INTERCEPTOR
axiosInstance.interceptors.request.use(
async (config) => {
if (['post', 'put', 'patch', 'delete'].includes(config.method.toLowerCase())) {
const csrfToken = await getCsrfToken();
config.headers['X-CSRFToken'] = csrfToken;
}
return config;
}
);
// Response interceptor
axiosInstance.interceptors.response.use(
response => response,
error => {
console.error('API request failed:', error);
return Promise.reject(error);
}
);
export default axiosInstance;- Create Navbar and Footer Components
Create src/components/Navbar.jsx:
export default function Navbar() {
return (
<nav>
<h1>My App</h1>
</nav>
);
}Create src/components/Footer.jsx:
export default function Footer() {
return (
<footer>
<p>© {new Date().getFullYear()} My App. All rights reserved.</p>
</footer>
);
}- Create
src/layouts/Root.jsx:
import { Outlet } from 'react-router-dom';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';
export default function Root() {
return (
<div>
<Navbar />
<main>
<Outlet />
</main>
<Footer />
</div>
);
}- Create Page Components
Create src/components/BackendStatus.jsx:
- Import axios from
../services/api, useState, useEffect - Initialize state:
status = "checking...",error = null - useEffect hook (runs on mount):
- First:
axios.get('/api/csrf/')to initialize cookies - Second:
axios.get('/api/health/')using same axios instance - Success path: update status with backend message
- Error path: set error state, display "Backend unreachable"
- First:
- Component is presentational only (no routing/layout logic)
Create src/pages/Home.jsx:
- Render
<BackendStatus /> - Add heading + text explaining the backend connectivity check
- Create
src/router/AppRoutes.jsx: - Export
createAppRouter()function - Returns route config array: Root layout at "/" with Home page as nested "/" child route
- Imports:
Rootfrom../layouts/Root,Homefrom../pages/Home
- Create
src/router/index.jsx: - Export default
AppRoutercomponent - Create browser router from
createAppRouter()config - Return
<RouterProvider router={router} /> - Imports:
createBrowserRouter,RouterProviderfrom react-router-dom,createAppRouterfrom./AppRoutes
- Update
src/App.jsx:
- Remove: All useState, demo imports (reactLogo, viteLogo, App.css), counter UI
- Add imports:
Routerfrom./router - Render:
<Router />
- Verify Setup
Run npm --prefix ./frontend run build to validate imports, dependencies, and syntax
Common issues:
- Missing certs: Check
/certs/directory exists with .pem files - Module not found: Verify all imports use correct paths
- CSRF errors: Ensure Django backend is running at
https://localhost:8000
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

