Repository navigation
feat: consolidate the marketing site and app into one server-rendered Expo app on the apex - #430
Merged
Merged
Conversation
Switches web.output to 'server' so marketing and public pages are crawlable and unfurl on social, instead of shipping an empty SPA shell. Three things had to change for the tree to render server-side. The readiness gate in _layout and the theme provider's gate both returned null until their effects had run, which on the server (where effects never run) emitted an empty document. The cookie-consent provider guarded on `typeof window`, which skipped its children on the server but rendered them on the client's first pass — a hydration mismatch (React #418) that made React discard the whole SSR tree. Global CSS lives in global.css, imported from _layout so Metro emits a real stylesheet link. Rendering <style> or <link> inside the react-native-web tree blanks the page on hydration, and a custom +html.tsx takes over <head> and drops the client-side <title>. Fonts move from expo-font to self-hosted WOFF2. The @expo-google-fonts barrels require() every weight, which shipped 36 TTFs (7.2 MB) for the four we use; deep per-weight imports plus WOFF2 brings that to 277 KB, and font-display: swap avoids the reflow that TTF-after-hydration caused. Mapbox's stylesheet is injected on demand rather than imported, since a static import is collected into Metro's global CSS and linked from every page — 40 KB of map styling on a landing page with no map.
scaffald.com was a separate Wix site, and apps/web held an undeployed Next.js replacement. Both are replaced by marketing surfaces inside the Expo app, so there is one codebase, one session and one deploy. Logged-out visitors to `/` get the landing page; signed-in users still go to the dashboard. The routing decision moved out of the component into a pure resolveRootRoute() — it was tangled with hooks and effects and could not be tested, which is how a platform assumption shipped: the landing page was served to unauthenticated *native* users, who should get the welcome/login flow. Native has no marketing surface. Web renders the landing while auth is pending as well as when logged out, so the client's first pass matches the server. Keying that on isServerRender alone caused a hydration mismatch. Legal copy is ported verbatim from apps/web, which is deleted here — its content lives in features/marketing/screens and content/faq.ts. FAQ copy is plain data with no component imports so the accordion and the FAQPage JSON-LD read from one source and cannot drift.
Public pages now carry what crawlers and unfurlers need, rendered on the server rather than assembled after hydration. generateMetadata supplies titles, descriptions, canonicals and Open Graph per route; the profile and job routes fetch their data in a loader first, so titles like "Alex Martinez | Scaffald" come from the database at request time. Missing records return noindex — the renderer has no route-level status override yet, so a real 404 needs a +middleware.ts and a second lookup. JSON-LD lives in components rather than metadata, because the Metadata type can only emit <meta> and never <script>. Organization, WebSite and FAQPage on the landing page; ProfilePage and JobPosting on the dynamic ones, the latter feeding Google Jobs. Sitemaps are API routes querying PostgREST directly, since the REST API exposes no bulk slug listing. Values are XML-escaped: one unescaped ampersand in a slug invalidates the document and Search Console rejects it silently. The social card is generated from docs/assets/og-image.html; og:image must be absolute or every major unfurler ignores it.
Replaces the Resend route from the retired Next.js site. Calls the Resend HTTP API directly rather than the SDK so it stays dependency-free and runs on any server runtime. The endpoint is public, unauthenticated and relays text into email, so it carries a honeypot and per-IP rate limiting. A tripped honeypot reports success so bots do not probe for the real check, but sends nothing. The rate limit is in-process, which is enough to blunt casual abuse; a shared store would be needed behind more than a couple of instances.
The landing page offers "Create Your Worker Profile" and "Register your Organization", but both landed on the same undifferentiated sign-in screen and the choice was discarded. The CTAs now pass an intent, and the sign-in screen restates it. Copy is translated for all three locales.
The native landing-page regression in this branch shipped without a single test failing, because the routing decision was unreachable from a test — it lived inside a component behind auth hooks. root-route.test.ts exercises the extracted resolver directly, including a sweep of all 72 platform/auth/state combinations asserting that only web ever renders marketing. platform-parity.test.ts checks that web-only modules have native counterparts, which is the class of mistake the regression belonged to. The remaining suites cover XML escaping in the sitemaps, the contact endpoint's honeypot and rate limiting, and the presence of metadata on public routes.
react-native-web has no native animated module, so `useNativeDriver: true` logged a "falling back to JS-based animation" warning on every drawer toggle and on a loop for the live indicator. The animation was already running in JS; only the noise is removed.
scaffald.com now serves the app; app.scaffald.com only 301s to it. Anything that emits a link a user clicks later — invitation emails, background-check and ID-verification notifications, OAuth redirects, shipped mobile builds — should point at the apex directly rather than through a redirect. The edge functions read EXPO_PUBLIC_URL / TEAM_APP_BASE_URL first; only the hardcoded fallback changes, but that fallback was what production actually used, since neither secret was set.
A server-output build has no static index.html, so the old S3 sync produced an unservable site — the next push to main or preview would have broken dev and preview. The workflow now runs `eas deploy` for every environment and hard-fails if the export is missing dist/server/_expo/routes.json, rather than uploading a broken bundle. Dev and preview keep their existing CloudFront distributions in front of alias deployments; a bare CNAME to an EAS alias cannot work, because EAS only serves TLS for hostnames it knows. The Supabase auth step now appends to uri_allow_list instead of replacing it, which would have dropped the other environments' origins on every production deploy. Route53 changes reference Z03807932GT9W30LQ0T67. The ID in these files, Z0610739109YR6SDKL45L, names no zone that exists — including in the IAM policy, which therefore granted access to nothing. Also lands an Express entry point, Dockerfile and deploy-ssr.sh for running dist/server ourselves. Production does not use them. They exist because EAS Hosting silently dropped generateMetadata output for a while, and this is the escape hatch if that recurs; the route code is identical either way.
The endpoint was ported from the retired Next.js site, which used Resend. Nothing else in this codebase does: notification email goes through SendGrid (packages/supabase/functions/_shared/notifications/adapters/email.ts). Keeping Resend meant a second provider to fund, warm and authenticate in SPF and DKIM, for one form. Sends from our own verified address with the submitter on reply-to. Using their address as the From fails SPF and DMARC for their domain and gets the sending account treated as a spoofer, so there is a test pinning it. This does not make the form work yet — SENDGRID_API_KEY is not set in the production edge function secrets either, so notification email is not sending in production at all. The endpoint reports 503 rather than pretending to succeed.
These were written in an earlier session and left untracked, so the only copy was in one working tree. Referenced by docs/agents/TRACKING.md and the digest issue (#394).
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scaffald.comwas a Wix site, the product ran onapp.scaffald.com, and an undeployed Next.js marketing site sat inapps/web. Three surfaces, one of which nobody could reach. Vanity URLs the app already hands out —scaffald.com/users/{slug}— 404'd on Wix.This makes the Expo app the whole site. Logged-out visitors to
/get marketing; signed-in users go to the dashboard; public profile and job pages are server-rendered and crawlable. LinkedIn's shape.This is already deployed. The apex has been serving it since 2026-07-28 — cutover, DNS, redirects and cache tuning were done live. This PR is the code catching up to production, so review is about correctness of what is running, not about what is about to ship.
What changed
web.output: 'server'with Expo Router's alpha server rendering and data loaders. Two providers returnednulluntil effects ran and so served an empty document; both now have server-render branches.packages/scf-core/features/marketing.apps/webis deleted; its legal copy is ported verbatim.generateMetadata, JSON-LD (Organization, WebSite, FAQPage, ProfilePage, JobPosting), four sitemap API routes.JobPostingfeeds Google Jobs.index.html.Worth a second look
utils/root-route.tsis a pure function because the version inside the component was untestable, and an untested platform assumption shipped: unauthenticated native users were served the web marketing page. The test sweeps all 72 platform/auth/state combinations and asserts only web ever lands.asyncRoutesis deliberately not enabled. It produces per-route chunks but breaks hydration under alpha SSR — every page serves correct HTML then blanks, with no console error. Bisected by toggling the flag alone.<style>or<link>inside the react-native-web tree; it blanks the page on hydration. Global CSS goes throughglobal.cssso Metro emits a real stylesheet link.infra/named a zone that does not exist, including in an IAM policy — so that policy granted access to nothing.Known gaps, tracked separately
SENDGRID_API_KEYis absent from the edge function secrets, so notification email is not sending at all and the contact form returns 503. The endpoint fails loudly rather than pretending to succeed.docs-site:buildand@scaffald/ui-docs:buildfail on this branch and onmainalike — a Docusaurus version mismatch inside thepackages/sdkandpackages/uisubmodules. Not from this branch.Verification
66 tests pass. Production was smoke-tested across the public routes after cutover: metadata, JSON-LD and loader data present in the served HTML, 60/60 requests clean at ~0.16s TTFB. Native login verified on the iOS simulator.