Skip to main content

No project description provided

Project description

React SSR (Backend)

A view for server-side render react apps from Django. Expected to be used in combination with React SSR (Frontend)

Installation

pip install react-ssr

Examples

<!-- index.html -->
{% extends "react_ssr/base.html" %}

{% load render_bundle from webpack_loader %}
{% load static %}

{% block head %}
    <script>window.__STATE__ == {{ state | safe }};</script>
{% endblock %}

{% block body %}
    <main role="main">{{ html | safe }}</main>
    {% render_bundle "runtime" %}
    {% render_bundle "vendors" %}
    {% render_bundle "client" %}
{% endblock %}
# urls.py
from django.conf.urls import url
from . import views

urlpatterns = [
    ...
    url(r"^$" views.HomePageView.as_view(), name="home-page"),
    ...
]
# views.py
from react_ssr.views import ReactView

class ReactViewBase(ReactView):
		included_context = ["title", "meta"]

class HomePageView(ReactViewBase):
		page_path = "site/pages/home"
		page_state_path = "site.pages.home"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

react-ssr-5.0.0.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

react_ssr-5.0.0-py3-none-any.whl (23.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page