Repository navigation
Replies: 2 comments
|
Short answer: for a rental site, SEO matters mostly on the public pages (home, search results, individual listings), and the template's frontend is a client-side SPA (React + Vite + TanStack Router). So the question is really "how do I serve real HTML for those public pages", and Bun is just one possible runtime for that, not the solution itself. Is plain React (SPA) good enough for SEO? What the "Bun container" actually means Three realistic options, from simplest:
Whichever you choose, the things that actually move SEO:
So: don't add Bun just because the AI suggested it. Start with option 1; if you later outgrow Jinja for the public side, moving to SSR is a well-trodden path. |
|
One quick thing to clear up first on how If you add a runtime Bun container for SSR, it wouldn't serve HTML to FastAPI—it sits in front of FastAPI behind Traefik, calls FastAPI's JSON API over the internal network, and returns rendered HTML to the browser/crawler. Building on what @adiletpn laid out, there are two template-specific gotchas before you ask AI to wire up a Bun SSR layer:
A simpler middle ground (no extra container, keep your React UI)If you want to stick to the template's React + shadcn/ui frontend without maintaining separate Jinja2 templates or adding a Bun runtime container, you can lean on how That means for public SEO pages (like import html
from pathlib import Path
from fastapi import HTTPException
from fastapi.responses import HTMLResponse
# Double-check the exact FRONTEND_DIR path in your backend/app/main.py
INDEX_PATH = Path("app/frontend/index.html")
@app.get("/listings/{listing_id}", response_class=HTMLResponse, include_in_schema=False)
def listing_seo_shell(listing_id: str, session: SessionDep) -> HTMLResponse:
listing = session.get(Listing, listing_id)
if not listing:
raise HTTPException(status_code=404)
title = html.escape(f"{listing.title} | YourSite")
desc = html.escape(listing.description[:160])
img = html.escape(listing.cover_image_url)
head_tags = (
f"<title>{title}</title>"
f'<meta name="description" content="{desc}">'
f'<meta property="og:title" content="{title}">'
f'<meta property="og:description" content="{desc}">'
f'<meta property="og:image" content="{img}">'
)
base_html = INDEX_PATH.read_text(encoding="utf-8")
# Match whatever default <title> is in frontend/index.html
rendered = base_html.replace("<title>FastAPI Project</title>", head_tags, 1)
return HTMLResponse(rendered)Pair that with a dynamic (Note: in local dev on When would a Bun SSR container actually be worth it? Mostly if you plan to build thousands of programmatic search/city landing pages where initial-HTML body text and crawl budget matter heavily across non-Google crawlers, or if you're happy migrating the frontend to an SSR framework up front. Otherwise, keeping the template's single FastAPI container + dynamic meta injection + sitemap gets you most of the SEO and all of the social link previews with very little to break. |
Uh oh!
There was an error while loading. Please reload this page.
First Check
Example Code
NoneDescription
I know fastAPI fairly well but I am not nearly as good with any frontend languages (have completed several projects without AI).
I am now working on a rental web service project. I was reading about SEO and I was including lots of instructions to stick to the template (using AI for this project). The AI wanted to use jinja 2 instead but later suggested using a bun container.
Reading up on it i think i get the idea that its a middle layer that serves clean html to fastapi backend. The big problem is that i have no idea if this is a good idea or not. Maybe react, when it comes to SEO is good enough?
I do get that adding a bun layer adds extra complexity and computing overhead, but i have no idea how much. So I am simply wondering if anyone has any input on this?
Operating System
Windows
Operating System Details
WSL
Project Version
0.12.0 (2026-08-12). From release_notes.md
Python Version
3.14
Additional Context
No response
All reactions