Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Barebones example of a Next.js SPA backed by a Django REST Framework API with JWT auth.
nextjs-django-boilerplate is a boilerplate template that pairs a Next.js single-page application (SPA) with a Django REST Framework API using JWT authentication.
nextjs-django-boilerplate is a barebones reference project that demonstrates a full-stack architecture where a Next.js frontend (in the www subfolder) consumes a Django REST Framework backend API. It includes JWT authentication, SQLite for development, and production deployment instructions for Heroku and Vercel.
www subdirectory..env file (via .env.sample) with SECRET_KEY; frontend uses NEXT_PUBLIC_API_HOST to point at the API.www subdirectory.python manage.py test.Developers who want to start a project with a Next.js frontend and a Django backend without building the integration boilerplate themselves. It is also useful for teams that need a reference for JWT cookie handling across separate subdomains.
CORS_ORIGIN_REGEX_WHITELIST and NEXT_PUBLIC_API_HOST.The README gives setup steps: create a virtualenv, install requirements from requirements/base.txt, configure .env with SECRET_KEY, run migrations, then start the API with python manage.py runserver 4001. On the frontend, cd www, npm install, then npm run dev to serve the UI at localhost:4000. For deployment, the backend is pushed to Heroku and the frontend to Vercel with specific env vars.
The backend uses SQLite by default. For production, the README explains adding Heroku Postgres, which sets the DATABASE_URL environment variable automatically.
Create a virtualenv, install requirements from requirements/base.txt, rename .env.sample to .env and set SECRET_KEY, then run python manage.py makemigrations api and python manage.py migrate. Start the server with python manage.py runserver 4001.
Switch to the www folder, run npm install, then npm run dev. The UI becomes available at http://localhost:4000.
Create a Heroku app, add Postgres, connect the repo, set config vars (SECRET_KEY, DATABASE_URL, CORS_ORIGIN_REGEX_WHITELIST, IGNORE_DOT_ENV_FILE=on), and deploy from GitHub.
Import the repo on Vercel, select the www subdirectory as the project root, add the NEXT_PUBLIC_API_HOST env var pointing to the deployed API URL, then build.
