{"id":28679580,"url":"https://github.com/psiace/starlive","last_synced_at":"2026-04-20T10:32:33.210Z","repository":{"id":296738401,"uuid":"994322604","full_name":"PsiACE/starlive","owner":"PsiACE","description":"Build dynamic, real-time web applications with automatic HTMX/Turbo detection and WebSocket streaming","archived":false,"fork":false,"pushed_at":"2025-06-01T20:14:54.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-07T06:36:52.822Z","etag":null,"topics":["fastapi","hotwire","htmx","hypermedia","starlette","turbo"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PsiACE.png","metadata":{"files":{"readme":"README.md","changelog":"changelogithub.config.json","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T17:37:02.000Z","updated_at":"2025-06-01T20:14:58.000Z","dependencies_parsed_at":"2025-06-02T03:42:22.395Z","dependency_job_id":null,"html_url":"https://github.com/PsiACE/starlive","commit_stats":null,"previous_names":["psiace/starlive"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/PsiACE/starlive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsiACE%2Fstarlive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsiACE%2Fstarlive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsiACE%2Fstarlive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsiACE%2Fstarlive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PsiACE","download_url":"https://codeload.github.com/PsiACE/starlive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PsiACE%2Fstarlive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32043025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","hotwire","htmx","hypermedia","starlette","turbo"],"created_at":"2025-06-14T01:43:28.115Z","updated_at":"2026-04-20T10:32:33.196Z","avatar_url":"https://github.com/PsiACE.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StarLive\n\n\u003e **Universal Hypermedia System for Starlette \u0026 FastAPI**\n\u003e\n\u003e Build dynamic, real-time web applications with automatic HTMX/Turbo detection and WebSocket streaming\n\n[![PyPI version](https://badge.fury.io/py/starlive.svg)](https://pypi.org/project/starlive/)\n[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nStarLive automatically detects HTMX/Turbo clients and provides unified streaming responses with real-time WebSocket updates.\n\n## Features\n\n- **Universal API**: One codebase for both HTMX and Turbo\n- **Auto-detection**: Framework detection via request headers\n- **Real-time**: WebSocket streaming to all clients\n- **Zero config**: Works out of the box\n\n## Installation\n\n```bash\npip install starlive\n```\n\n## Quick Start\n\n```python\nfrom starlette.applications import Starlette\nfrom starlette.responses import HTMLResponse\nfrom starlette.routing import Route\nfrom starlive import StarLive, StarLiveMiddleware\n\nstarlive = StarLive()\n\nasync def homepage(request):\n    return HTMLResponse(f\"\"\"\n    \u003chtml\u003e\n    \u003chead\u003e{starlive.get_scripts()}\u003c/head\u003e\n    \u003cbody\u003e\n        \u003cdiv id=\"content\"\u003e\n            \u003cbutton hx-post=\"/update\" hx-target=\"#content\"\u003eUpdate\u003c/button\u003e\n        \u003c/div\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n    \"\"\")\n\nasync def update_content(request):\n    if request.state.can_stream():\n        content = '\u003cdiv\u003eUpdated!\u003c/div\u003e'\n        if request.state.hypermedia_type == \"htmx\":\n            return HTMLResponse(content)\n        else:  # Turbo\n            stream = starlive.update(content, \"#content\",\n                                   hypermedia_type=request.state.hypermedia_type)\n            return starlive.stream(stream, request.state.hypermedia_type)\n    return HTMLResponse(\"Updated!\")\n\napp = Starlette(routes=[\n    Route(\"/\", homepage),\n    Route(\"/update\", update_content, methods=[\"POST\"]),\n])\n\napp.add_middleware(StarLiveMiddleware, starlive=starlive)\napp.router.routes.append(starlive.create_websocket_route())\n```\n\n## FastAPI\n\n```python\nfrom fastapi import FastAPI, WebSocket\nfrom starlive import StarLive, StarLiveMiddleware\n\nstarlive = StarLive()\napp = FastAPI()\napp.add_middleware(StarLiveMiddleware, starlive=starlive)\n\n@app.websocket(starlive.ws_route)\nasync def websocket_endpoint(websocket: WebSocket):\n    await starlive._websocket_endpoint(websocket)\n\n# Use same handlers as Starlette example\n```\n\n## Stream Operations\n\n```python\n# All work with both HTMX and Turbo\nstarlive.append(content, \"#target\")\nstarlive.prepend(content, \"#target\")\nstarlive.replace(content, \"#target\")\nstarlive.update(content, \"#target\")\nstarlive.remove(\"#target\")\nstarlive.before(content, \"#target\")\nstarlive.after(content, \"#target\")\n```\n\n## Real-time Updates\n\n```python\n# Broadcast to all clients\nawait starlive.push(\n    starlive.append('\u003cdiv\u003eNew message\u003c/div\u003e', \"#messages\"),\n    to=None\n)\n\n# Custom user identification\n@starlive.user_id\ndef get_user_id():\n    return request.session.get(\"user_id\", \"anonymous\")\n```\n\n## Request Detection\n\n```python\nif request.state.hypermedia_type == \"htmx\":\n    return HTMLResponse(\"\u003cdiv\u003eHTMX response\u003c/div\u003e\")\nelif request.state.hypermedia_type == \"turbo\":\n    return starlive.stream(starlive.update(content, \"#target\"), \"turbo\")\nelse:\n    return JSONResponse({\"data\": \"value\"})\n```\n\n## Templates\n\n```python\nfrom starlette.templating import Jinja2Templates\nfrom starlive import starlive_context_processor\n\ntemplates = Jinja2Templates(directory=\"templates\")\ntemplates.env.globals.update(starlive_context_processor(starlive)())\n```\n\n```html\n\u003chead\u003e\n  {{ starlive.get_scripts() }}\n\u003c/head\u003e\n```\n\n## Examples\n\n```bash\n# Interactive demo\nuv run starlive-dev\n\n# Specific frameworks\nuv run starlive-dev --framework starlette  # http://localhost:8001\nuv run starlive-dev --framework fastapi    # http://localhost:8002\n```\n\n## Development\n\n```bash\ngit clone https://github.com/yourusername/starlive.git\ncd starlive\nuv sync --dev\n```\n\n### Testing\n\n```bash\nuv run starlive-test                    # All tests\nuv run starlive-test --framework fastapi   # FastAPI only\nuv run starlive-test --type e2e             # End-to-end only\nuv run starlive-test --coverage             # With coverage\n```\n\n### Code Quality\n\n```bash\nuv run ruff check src/ tests/ examples/\nuv run ruff format src/ tests/ examples/\n```\n\n## License\n\nApache 2.0 License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsiace%2Fstarlive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsiace%2Fstarlive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsiace%2Fstarlive/lists"}