django-react-integration
Wiring a React or SPA frontend to Django — same-origin vs separate-origin topologies, CorsMiddleware ordering, session vs JWT auth, a typed client from…
Skill by ajyadav013
Chalk Labs
Need help deploying django-react-integration?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ajyadav013-django-react-integration
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, backend, security, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/django-react-integration
What's inside
- Skill name
django-react-integration- Description
- Wiring a React or SPA frontend to Django — same-origin vs separate-origin topologies, CorsMiddleware ordering, session vs JWT auth, a typed client from drf-spectacular, static/media split. Use when a Django project has a React/SPA frontend.
- License
- MIT
- Instructions
- 148 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
Use this when a Django project serves, or is consumed by, a React or other SPA frontend. It covers
the two topologies, and the handful of things that are wrong by default in each.
## When to use
- Standing up a React frontend against a Django API
- Choosing between serving the SPA from Django and deploying it separately
- CORS requests failing, or succeeding but dropping cookies
- Deciding session auth vs JWT for a browser client
- Generating a typed API client so the frontend stops hand-writing response types
- Static and media files 404ing in production
## Pick a topology first
Almost every problem below is a consequence of this choice, so make it explicitly.
### A. Same origin — Django serves the bundle
cookiecutter-django's `frontend_pipeline` option (Gulp or Webpack) sets this up. Django serves the
HTML shell and the built assets; the SPA calls `/api/...` on its own origin.
- **No CORS at all.** Same origin means the whole class of problems does not exist.
- **Session auth works out of the box**, cookies included.
- Simplest deployment: one service, one domain.
- Cost: frontend and backend deploy together, and the frontend build is coupled to Django's static
pipeline.
**The dev port trap.** With Gulp or Webpack, `npm run dev` runs the asset build and Django in
parallel, and the URL to open is **`http://localhost:3000`**. Opening `:8000` still serves pages —
Django is up — but unstyled, with every static asset 404ing. It looks like a broken install. It is
the wrong port. With `frontend_pipeline: None` or Django Compressor, `:8000` is correct.
### B. Separate origins — Vite/Next dev server, independent deploy
The frontend is its own app on its own origin, talking to Django over HTTP.
- Independent deploys and independent scaling.
- Frontend tooling stays idiomatic (Vite HMR, the framework's own dev server).
- Cost: CORS, cookie policy, and auth all become real decisions.
## Separate-origin wiring
### CORS middleware order is not optional
```python
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware", # MUST be above CommonMiddleware
"django.middleware.common.CommonMiddleware",
...
]
CORS_ALLOWED_ORIGINS = ["https://app.example.com"] # never CORS_ALLOW_ALL_ORIGINS in production
CORS_ALLOW_CREDENTIALS = True # only if using session/cookie auth
```
`CorsMiddleware` must sit **above** `CommonMiddleware`. Below it, `CommonMiddleware` can respond or
redirect before the CORS headers are attached, and the preflight fails in a way that looks like a
server error rather than a configuration mistake.
Enumerate origins. `CORS_ALLOW_ALL_ORIGINS = True` with `CORS_ALLOW_CREDENTIALS = True` is rejected
by browsers anyway, and is a hole regardless.
### Session vs JWT for a browser client
| | Session cookies | JWT |
|---|---|---|
| Storage | `HttpOnly` cookie — unreachable from JS | Usually JS-readable storage |
| XSS exposure | Token cannot be exfiltrated by script | Token can be stolen |
| Revocation | Immediate, server-side | Not until expiry, without a denylist |
| CSRF | Needs protection | Not applicable with header auth |
| Cross-origin | Needs `SameSite=None; Secure` + `CORS_ALLOW_CREDENTIALS` | Simpler |
| Mobile / third-party clients | Awkward | Natural fit |
**Default to session auth for a first-party browser SPA.** The `HttpOnly` cookie is a real security
property that JWT-in-localStorage gives away, and "we might add a mobile app" is not a reason to
take that loss today.
Reach for JWT when clients are genuinely not browsers on your domain, or when the API is consumed
by third parties.
With session auth cross-origin, you need:
```python
SESSION_COOKIE_SAMESITE = "None" # cross-site requests
SESSION_COOKIE_SECURE = True # required whenever SameSite=None
CSRF_TRUSTED_ORIGINS = ["https://app.example.com"]
```
and the frontend must send `credentials: "include"` and echo the CSRF token on unsafe methods.
## Generate the client, do not hand-write it
`drf-spectacular` produces an OpenAPI 3 schema; generate TypeScript from it rather than
maintaining response interfaces by hand.
```bash
uv run python manage.py spectacular --file schema.yml
npx openapi-typescript schema.yml -o src/api/schema.d.ts
```
Wire both into CI: regenerate and fail on a diff. Otherwise the generated types drift from the
serializers and the type checker starts confidently lying. Hand-written interfaces have the same
failure mode with no signal at all.
## Production static and media
Two different things, routinely conflated:
- **Static** — your CSS, JS, images. Collected by `collectstatic`, served by whitenoise or a CDN.
- **Media** — user uploads. Never served by Django in production; use django-storages against S3,
GCS, or Azure.
```python
STATIC_ROOT = BASE_DIR / "staticfiles" # collectstatic target
STATIC_URL = "/static/"
```
The SPA bundle is *static*. Under topology B it is usually served entirely by the frontend host or
CDN and Django serves only the API — in which case Django's static config still matters for theFrom ajyadav013/claude-kit, MIT.
More from ajyadav013/claude-kit
- 0.602score
data-engineering-bigquery-gcs
ajyadav013
BigQuery medallion architecture (bronze/silver/gold), parameterized queries, MERGE upserts, partitioning, CDC dedup, Temporal orchestration.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
async-python-patterns
ajyadav013
Async Python for high-performance services.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
auth-and-rbac
ajyadav013
FastAPI auth patterns — session/JWT chains, argon2id hashing, pyotp TOTP/Email OTP, role-based access control, x-user-data gateway forwarding.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
backend-repo-architecture
ajyadav013
Canonical backend repository structure for Python/FastAPI — multi-mode entrypoint, app factory, ConnectionManager, BaseDao, flat vs versioned layout.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
api-and-interface-design
ajyadav013
Stable API and interface design patterns.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
api-pagination-filtering-sorting
ajyadav013
HTTP query parameter conventions for pagination, filtering, sorting, and search with standardized response metadata.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
code-simplification
ajyadav013
Simplifies/refactors working code for clarity without changing behavior.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
docker-shared
ajyadav013
Shared Docker building blocks — base images for private registries, .dockerignore conventions, compose fragment reuse with YAML anchors.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
dockerfile-backend
ajyadav013
Multi-stage Dockerfiles for Python/FastAPI backends — builder vs runtime, slim vs alpine, system deps, layer caching, non-root users.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
cron-and-scheduled-jobs
ajyadav013
Scheduled jobs across two mechanisms — Kubernetes CronJobs (schedule in Helm values, MODE=cron) and Temporal Schedules.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
anthropic-vertex-integration
ajyadav013
Claude on Vertex AI via the AnthropicVertex SDK — lazy ADC client init, env-based project/region resolution, async helpers, backoff retry.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
design-patterns-and-conventions
ajyadav013
Cross-cutting design patterns, naming, folder layout, and anti-patterns for production Python/FastAPI backends.
SkillBFreshness: B★ 14Claude Code +9
Signals
- Stars
- 14
- Forks
- 5
- Open issues
- 9
- Last commit (this folder)
- Aug 22, 2026 (2 months ago)
- Last release
- Sep 7, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ajyadav013/claude-kit
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from ajyadav013
- 0.602score
anthropic-vertex-integration
ajyadav013
Claude on Vertex AI via the AnthropicVertex SDK — lazy ADC client init, env-based project/region resolution, async helpers, backoff retry.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
dockerfile-backend
ajyadav013
Multi-stage Dockerfiles for Python/FastAPI backends — builder vs runtime, slim vs alpine, system deps, layer caching, non-root users.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
code-simplification
ajyadav013
Simplifies/refactors working code for clarity without changing behavior.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
cron-and-scheduled-jobs
ajyadav013
Scheduled jobs across two mechanisms — Kubernetes CronJobs (schedule in Helm values, MODE=cron) and Temporal Schedules.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
docker-shared
ajyadav013
Shared Docker building blocks — base images for private registries, .dockerignore conventions, compose fragment reuse with YAML anchors.
SkillBFreshness: B★ 14Claude Code +9 - 0.602score
api-and-interface-design
ajyadav013
Stable API and interface design patterns.
SkillBFreshness: B★ 14Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get django-react-integration running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
django-react-integration skill. Agent Mart. https://agentmart.dev/skills/ajyadav013-django-react-integration (last updated 2026-10-24)