Django Frontend Kit is an opinionated frontend scaffolder for Django, integrating seamlessly with ViteJS. It provides a streamlined setup for modern frontend tooling within your Django projects, enabling efficient development and production workflows.
- 📦 Seamless ViteJS Integration – Enables modern frontend tooling in Django.
- ⚡ Zero Config Development – Uses Vite’s dev server automatically during development.
- 🔧 Production-Ready Setup – Manages static assets via Django’s
collectstaticmechanism. - 🛠 Easy Scaffolding – One command to generate the required frontend structure.
You can install django-frontend-kit using your preferred package manager:
uv add django-frontend-kitpoetry add django-frontend-kitpip install django-frontend-kitIn your settings.py, add django-frontend-kit to INSTALLED_APPS:
INSTALLED_APPS = [
...
"frontend_kit",
...
]By default, django-frontend-kit looks for a frontend directory specified by DJFK_FRONTEND_DIR. It is recommended to place it in the root of your project:
DJFK_FRONTEND_DIR = BASE_DIR / "frontend"For Django template engine to find the frontend files, add DJFK_FRONTEND_DIR to TEMPLATES DIRS in settings.py:
TEMPLATES = [
{
...
"DIRS": [
...
DJFK_FRONTEND_DIR
...
],
...
}
]During development, django-frontend-kit will use Vite's dev server. Set the dev server URL:
VITE_DEV_SERVER_URL = "http://localhost:5173/"To collect staticfiles built by Vite, add the VITE_OUTPUT_DIR to STATICFILES_DIRS in settings.py:
VITE_OUTPUT_DIR = os.environ.get("VITE_OUTPUT_DIR", "./dist")
STATICFILES_DIRS = [VITE_OUTPUT_DIR]Run the following command to create the required frontend structure:
python manage.py scaffoldThis will generate the frontend directory and Vite configuration in BASE_DIR.
Create a package.json file:
npm init -yInstall the necessary dependencies:
npm install vite @iamwaseem99/vite-plugin-django-frontend-kitTo start the development server, run:
npm run dev To generate production-ready frontend assets, run:
npm run buildand run the following command to collect static files:
python manage.py collectstatic - [] Add philosophy.
- [] Explain the project structure.
- [] Add how to add and use layouts, pages, shared files.
- [] Add how to use third party libraries like tailwind, react, alpine, etc.
This project is licensed under the MIT License - see the LICENSE file for details.