spa-subdomain-root-render

Render React Router SPAs at subdomain roots with edge-injected user data.

46|28|Updated Sep 8, 2025
One-click install
npx skills add https://github.com/divinevideo/divine-web --skill spa-subdomain-root-render
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spa-subdomain-root-render
Source: https://github.com/divinevideo/divine-web/tree/main/.agents/skills/spa-subdomain-root-render
Command: npx skills add https://github.com/divinevideo/divine-web --skill spa-subdomain-root-render

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of subdomain-based SPAs redirecting away from the subdomain root and rendering blank content when a React Router component expects route parameters that do not exist at "/".

Core Features & Use Cases

  • Redirect-free router rendering at subdomain root: Render the target page at "/" (instead of using Navigate) so username.domain.com/ stays clean and feels like a personal website.
  • Fallback identifier logic for missing params: Use injected subdomain user data when useParams() has no matching values at the root route.
  • Edge-injected global user context: Inject user data into the SPA HTML before hydration so the client can reliably read it during initial render.
  • Use Case: When thecomedianriley.divine.video/ should show the profile page at "/" rather than redirecting to something like "/profile/npub1...", this pattern keeps the URL stable and ensures the component still loads.

Quick Start

Follow the steps in the SKILL.md to render the profile component directly at the "/" route, add a fallback that uses edge-injected subdomain data when useParams() is empty, and inject the user JSON in the edge worker before SPA hydration.

Frequently Asked Questions about spa-subdomain-root-render

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my React Router SPA render a blank screen at the subdomain root?

Your React Router SPA renders a blank screen at the subdomain root because components relying on useParams() fail when parameters are absent. Adding client fallback logic to read edge-injected global user data fixes this missing param issue.

How do I render a subdomain root page in React Router without redirecting?

To render a subdomain root page without redirects, remove the Navigate component and render the target component directly at the "/" route. Use edge-injected global user context as a fallback when useParams() returns empty.

What is edge injection for client hydration in a subdomain SPA?

Edge injection for client hydration is placing serialized user data into the initial HTML before SPA hydration. This allows the client to reliably read subdomain user context during initial render without extra network fetches.

Can I use useParams() fallback logic with edge worker injected data?

Yes, you can use useParams() fallback logic with edge worker injected data by reading serialized user JSON from the global window context. This prevents blank screens when the root route lacks profile identifiers.

How do I inject user JSON into SPA HTML before hydration?

You inject user JSON into SPA HTML before hydration by adding an edge worker step that places serialized subdomain user data into the initial HTML response. The client then reads this global data during initial render.

When should I avoid redirect-free subdomain root rendering?

You should avoid redirect-free subdomain root rendering if your SPA components lack client fallback logic for missing route params. This pattern requires an edge worker to inject global user data and components handling empty useParams() values.