![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@friendofsvelte/django-kit
Advanced tools
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
It promotes SvelteKit's forms-actions heavily, and provides a way to use Django's forms, and validation with SvelteKit without any hassle.
People usually use fetch
to send data to the backend, and then handle the response. This is a good way to do it, but
it reduces the reactivity of SvelteKit. Django Kit provides a way to use Django's forms and validation with SvelteKit
keeping the reactivity intact, $page.form
is updated automatically when the form is submitted.
Using Django's Djapy is recommended for a more seamless integration.
First, in your SvelteKit project, install the package using npm:
In your SvelteKit project, install the package using npm:
npm install @friendofsvelte/django-kit
Use the package in your SvelteKit project, in your +page.server.ts
:
import {via_route_name} from '@friendofsvelte/django-kit';
export const actions = via_route_name(["login", "register", "logout"]);
// you need to setup django-kit-fos in your Django project
The via_route_name
function takes an array of route names, and returns an object with the same keys. The object has
functions that can be used to submit forms to the backend.
You can call GET
or POST
api endpoints using the functions returned by via_route_name
.
import {via_route_name} from '@friendofsvelte/django-kit';
export const actions = via_route_name([{name: "search_users", method: "GET"}]);
// converts the search formdata to query params
The via_route_path
function takes an array of route paths, and returns an object with the same keys. The object has
functions that can be used to submit forms to the backend.
import {via_route_path} from '@friendofsvelte/django-kit';
export const actions = via_route_path(["/login", "/register", "/logout"]);
This can also be used to call GET
or POST
api endpoints using the functions returned by via_route_path
.
You can also pass route prefix, and the function will automatically prepend the prefix to the route path.
import {via_route_path} from '@friendofsvelte/django-kit';
export const actions = via_route_path(["login", "register", "logout"], "/api");
If you're using Django as a backend, you can use the django-kit-fos
package to integrate Django with SvelteKit.
In your Django project, install the package using pip:
pip install django-kit-fos
In your Django project, add the following to your urls.py
:
from django.urls import path
from django_kit_fos import trigger_pattern
urlpatterns = [
# Your other paths
] + trigger_pattern
FAQs
This is a simple library that helps you integrate SvelteKit with Django. It provides a simple way to use Django as a backend and SvelteKit as a frontend, without hampering the reactivity provided by SvelteKit.
The npm package @friendofsvelte/django-kit receives a total of 21 weekly downloads. As such, @friendofsvelte/django-kit popularity was classified as not popular.
We found that @friendofsvelte/django-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.