An open API service indexing awesome lists of open source software.

https://github.com/krmax44/vue-ssr-python

Python and Django client for vue-ssr-service
https://github.com/krmax44/vue-ssr-python

django django-vue server-side-rendering ssr vue

Last synced: about 1 month ago
JSON representation

Python and Django client for vue-ssr-service

Awesome Lists containing this project

README

          

# Vue Server-Side Rendering in Python

[![Test Workflow](https://github.com/krmax44/vue-ssr-python/actions/workflows/test.yaml/badge.svg)](https://github.com/krmax44/vue-ssr-python/actions/workflows/test.yaml)
[![PyPI - Version](https://img.shields.io/pypi/v/vue-ssr)](https://pypi.org/project/vue-ssr/)
[![API documentation](https://img.shields.io/badge/-api%20docs-blue)](https://krmax44.github.io/vue-ssr-python/vue_ssr.html)

Client for [`vue-ssr-service`](https://github.com/krmax44/vue-ssr-service). See its documentation for a [quick start guide](https://github.com/krmax44/vue-ssr-service#getting-started-with-vite).

> [!WARNING]
> This project is in a proof-of-concept state.

## Stand-alone

```python
from vue_ssr import ServerRenderer

renderer = ServerRenderer()
renderer.render("myComponent", props={"name": "friend"})
# "

Hello, friend!

"
```

## With Django

Works well in conjunction with [`django-vite`](https://github.com/MrBin99/django-vite). Add it to your installed apps:

```py
INSTALLED_APPS = [
"vue_ssr",
...
]
```

Then, you can simply use the provided template tag:

```django
{% load vue_ssr %}
{% render_vue "userGreeting" name=request.user.username %}
```

Or pass a dict with props:

```django
{% render_vue "myApp" props=props %}
```