Repository navigation
Add serveStaticAsset for custom routing and a TanStack Start SSR example - #3
Merged
Merged
Conversation
Forward `--preview-name <name>` to every `convex run` the uploader makes, so static files can be uploaded to a named preview deployment. It cannot be combined with `--prod`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the lookup and response building into an internal `serveAsset` that returns null when no file matches. `registerStaticRoutes` keeps the path decoding, prefix stripping, `/` -> `/index.html`, the 503 setup page and the 404, so its behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`serveStaticAsset(ctx, component, request, options?)` serves an uploaded file from an app-owned HTTP action and returns null when no file matches, so the app can write its own routing order: server rendering, prerendered pages next to an SPA shell, canonical redirects. Found files get the same response as `registerStaticRoutes`. The lookup is exact by default (`/` is not mapped to `/index.html` and `spaFallback` defaults to false), so the SPA shell never answers for a route the app handles. `path` looks up a different file, such as the shell. Also export `decodeRequestPath` so app path checks see the same decoded path. `registerStaticRoutes` is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Publishing a deployment used to delete the previous deployment's files right away, so a page that was already open could no longer load its lazy-loaded scripts or styles. Replaced storage files now move to a `retiredAssets` table for seven days. A request for a missing file with an extension, except HTML, gets the newest replaced copy. Old HTML never comes back, and paths without an extension keep the current SPA fallback. Later uploads delete expired files, and every cleanup path skips files that have not expired. Legacy CDN blobs are not retained. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add example-ssr/, which renders TanStack Start pages inside a Convex HTTP action. One catch-all route serves uploaded files with `serveStaticAsset`, returns 404 for missing `/assets/` files, and renders every other path. The page reads a click counter through Convex's TanStack Query integration: the count and the render time are in the server's HTML, and the count stays live after hydration. `npm run dev` keeps a dev deployment in sync: `convex dev --start` pushes the backend, and on each change the example rebuilds its bundles and uploads the browser files. The example is an npm workspace, so a root `npm install` installs it and links it to this package. It needs its own package.json because the Convex CLI reads package.json and convex.json from the directory it runs in. Root typecheck and lint include it, and CI builds it before running them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the seven-day retention implementation, tests, and documentation from the custom routing PR. Keep the preview upload option, serveStaticAsset API, and SSR example together.
chokidar-cli starts a new build and upload for every change without waiting for the previous one. Two builds could write dist at once, and an older upload could publish last and remove scripts that the newer server bundle requests. The watcher script queues one more run instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Same branch as upstream get-convex/static-hosting#41. A push to this branch updates both PRs.
serveStaticAssetserves one static file from a custom HTTP route, so an app can choose its own routing and server-side rendering fallback.upload --preview-nameuploads to a named preview deployment.example-ssrshows TanStack Start SSR on Convex HTTP actions.This PR does not depend on the asset retention PR. The two merge in either order without conflicts.
Merge with a merge commit, not a squash, so the fork history still matches the upstream PR.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.