Repository navigation
feat: add astro frontend support - #826
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughAdds comprehensive Astro frontend support across the CLI, template generator, templates, processors, types, tests, docs, and web UI; integrates Astro with ORPC, Better Auth, Cloudflare/Alchemy, and build tooling, and updates compatibility and validation rules to account for Astro. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 10
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/template-generator/templates/packages/env/src/web.ts.hbs (1)
45-50: Add auth-specific PUBLIC_ variables for Astro/Svelte when using Convex.The Astro/Svelte branch (lines 45-50) is missing conditional auth-specific environment variables that are present in other frameworks (Next.js, Vite). When Better Auth or Clerk is selected, validation and runtime access will fail because
PUBLIC_CONVEX_SITE_URL(Better Auth) andPUBLIC_CLERK_PUBLISHABLE_KEY(Clerk) are not defined.Proposed fix
{{else if (or (includes frontend "svelte") (includes frontend "astro"))}} clientPrefix: "PUBLIC_", client: { PUBLIC_CONVEX_URL: z.url(), +{{`#if` (eq auth "better-auth")}} + PUBLIC_CONVEX_SITE_URL: z.url(), +{{/if}} +{{`#if` (eq auth "clerk")}} + PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1), +{{/if}} }, runtimeEnv: (import.meta as any).env,apps/web/content/docs/index.mdx (1)
149-149: Addastroto the--frontendflags list.The docs list omits the new Astro option.
✏️ Suggested doc update
-- `--frontend`: tanstack-router, react-router, tanstack-start, next, nuxt, svelte, solid, native-bare, native-uniwind, native-unistyles, none +- `--frontend`: tanstack-router, react-router, tanstack-start, next, nuxt, svelte, solid, astro, native-bare, native-uniwind, native-unistyles, noneapps/cli/src/utils/compatibility-rules.ts (1)
47-85: Update self-backend error copy to include Astro.
FULLSTACK_FRONTENDSnow includesastro, but the error messages still list only Next/TanStack/Nuxt. That’s misleading for users.✏️ Suggested message updates
- "Backend 'self' (fullstack) currently only supports Next.js, TanStack Start, and Nuxt frontends. Please use --frontend next, --frontend tanstack-start, or --frontend nuxt. Support for SvelteKit will be added in a future update.", + "Backend 'self' (fullstack) currently only supports Next.js, TanStack Start, Nuxt, and Astro frontends. Please use --frontend next, --frontend tanstack-start, --frontend nuxt, or --frontend astro. Support for SvelteKit will be added in a future update.",- "Backend 'self' (fullstack) currently only supports Next.js, TanStack Start, and Nuxt frontends. Please use --frontend next, --frontend tanstack-start, --frontend nuxt, or choose a different backend. Support for SvelteKit will be added in a future update.", + "Backend 'self' (fullstack) currently only supports Next.js, TanStack Start, Nuxt, and Astro frontends. Please use --frontend next, --frontend tanstack-start, --frontend nuxt, --frontend astro, or choose a different backend. Support for SvelteKit will be added in a future update.",
🧹 Nitpick comments (12)
convex-astro/.gitignore (1)
16-26: Broaden env file ignores to avoid leaking variant configs.Right now only
.env,.env.production, and.env.localare ignored. Consider ignoring all.env.*variants (e.g.,.env.development,.env.test,.env.production.local) while keeping.env.exampletrackable.♻️ Suggested update
# environment variables .env .env.production +.env.* +!.env.example @@ -.env.localpackages/template-generator/src/processors/turbo-generator.ts (1)
76-79: Misleading comment —.astro/**is a build cache directory, not the output.The comment says "Astro outputs to dist/**" but the code adds
.astro/**. Astro's final build output goes todist/**(already included in line 61), while.astro/is the intermediate build/cache directory (similar to.next/for Next.js).📝 Suggested comment fix
- // Astro outputs to dist/** + // Astro uses .astro/** for build cache (final output is dist/**) if (frontend.includes("astro")) { buildOutputs.push(".astro/**"); }apps/web/content/docs/cli/programmatic-api.mdx (1)
20-22: Consider multi-line formatting for better maintainability.The inline
TabsContentelements with embedded code blocks work functionally but reduce source readability and make future edits more difficult.📝 Suggested formatting for improved readability
- <TabsContent value="npm">```bash npm install create-better-t-stack ```</TabsContent> - <TabsContent value="pnpm">```bash pnpm add create-better-t-stack ```</TabsContent> - <TabsContent value="bun">```bash bun add create-better-t-stack ```</TabsContent> + <TabsContent value="npm"> + ```bash + npm install create-better-t-stack + ``` + </TabsContent> + <TabsContent value="pnpm"> + ```bash + pnpm add create-better-t-stack + ``` + </TabsContent> + <TabsContent value="bun"> + ```bash + bun add create-better-t-stack + ``` + </TabsContent>convex-astro/src/lib/convex.tsx (1)
11-21: Consider using standard function declaration for the returned component.Per coding guidelines, functions should use standard function declaration syntax rather than arrow functions.
♻️ Suggested refactor
export function withConvexProvider<Props extends JSX.IntrinsicAttributes>( Component: FunctionComponent<Props>, ) { - return function WithConvexProvider(props: Props) { - return ( - <ConvexProvider client={client}> - <Component {...props} /> - </ConvexProvider> - ); - }; + function WithConvexProvider(props: Props) { + return ( + <ConvexProvider client={client}> + <Component {...props} /> + </ConvexProvider> + ); + } + return WithConvexProvider; }convex-astro/package.json (1)
14-22: Move@types/*packages todevDependencies.Type definition packages (
@types/react,@types/react-dom) are only needed at build/development time, not at runtime. They should be indevDependencies.Suggested fix
"dependencies": { "@astrojs/react": "^4.4.2", - "@types/react": "^19.2.6", - "@types/react-dom": "^19.2.3", "astro": "^5.16.0", "convex": "^1.31.0", "react": "^19.2.1", "react-dom": "^19.2.1" }, "devDependencies": { "@tailwindcss/vite": "^4.1.17", + "@types/react": "^19.2.6", + "@types/react-dom": "^19.2.3", "npm-run-all2": "^8.0.4",packages/template-generator/templates/auth/better-auth/web/astro/src/components/SignInForm.astro.hbs (1)
1-3: Remove unused frontmatter import.The
authClientimport in the frontmatter (server-side) is not used. It's only needed in the client-side<script>block where it's already imported on line 53.Suggested fix
--- -import { authClient } from "../lib/auth-client"; ---packages/template-generator/templates/frontend/astro/src/layouts/Layout.astro.hbs (1)
5-7: Use a type alias forPropsto match project TS conventions.Line 5 declares an
interface; switch to atypealias to align with the TS guideline.♻️ Suggested change
-interface Props { - title?: string; -} +type Props = { + title?: string; +};As per coding guidelines, please use type aliases.
packages/template-generator/templates/api/orpc/server/src/context.ts.hbs (1)
67-75: Prefer explicit auth branches in HandlebarsThe bare
{{else}}makes the fallback implicit. Please enumerate the supported auth modes (e.g.,nonevsbetter-auth) so new providers don’t silently fall into the no-auth path. As per coding guidelines, avoid generic if/else blocks in Handlebars.♻️ Suggested adjustment
{{`#if` (eq auth "better-auth")}} const session = await auth.api.getSession({ headers }); return { session, }; -{{else}} - return {}; +{{else if (eq auth "none")}} + return {}; {{/if}}packages/template-generator/templates/api/orpc/fullstack/astro/src/pages/rpc/[...rest].ts.hbs (1)
17-26: Use a function declaration for the route handlerThe style guide prefers standard function declarations over arrow functions. As per coding guidelines, please switch this handler to a function declaration.
♻️ Proposed change
-export const ALL: APIRoute = async ({ request }) => { +export async function ALL({ request }: Parameters<APIRoute>[0]) { const context = await createContext({ headers: request.headers }); const { response } = await handler.handle(request, { prefix: "/rpc", context, }); return response ?? new Response("Not found", { status: 404 }); -}; +}packages/template-generator/templates/examples/todo/web/astro/src/pages/todos.astro.hbs (1)
35-39: Use a type alias instead of an interfacePlease use a type alias here for consistency with the TS style rules. As per coding guidelines, prefer type aliases over interfaces.
♻️ Suggested change
- interface Todo { - id: number; - text: string; - completed: boolean; - } + type Todo = { + id: number; + text: string; + completed: boolean; + };convex-astro/convex/comments.ts (1)
10-20: Prefer method shorthand over arrow handlers.
Repo guidelines ask for standard function declarations; usingasync handler(...) {}inside the config keeps consistency. As per coding guidelines, ...convex-astro/src/components/CommentList.tsx (1)
6-29: Extract the arrow callback into a named function declaration to align with the function-declaration guideline.The
mapcallback at line 14 uses an arrow function. Extract it as a named function declaration.♻️ Proposed refactor
export default withConvexProvider(function CommentList() { const comments = useQuery(api.comments.list); + function renderComment(comment: NonNullable<typeof comments>[number]) { + return ( + <article + key={comment._id} + className="rounded-lg border border-gray-200 bg-gray-50 p-4 shadow-sm" + > + <header className="mb-2 flex items-center justify-between"> + <strong className="font-medium text-gray-900">{comment.author}</strong> + <span className="text-sm text-gray-500"> + {new Date(comment._creationTime).toLocaleDateString()} + </span> + </header> + <main className="leading-relaxed text-gray-700"> + <p className="whitespace-pre-line">{comment.content}</p> + </main> + </article> + ); + } return comments === undefined ? ( <p className="py-4 text-center text-gray-500">Loading comments...</p> ) : comments.length === 0 ? ( <p className="py-4 text-center text-gray-500">No comments found.</p> ) : ( <div className="space-y-6"> - {comments.map((comment) => ( - <article - key={comment._id} - className="rounded-lg border border-gray-200 bg-gray-50 p-4 shadow-sm" - > - <header className="mb-2 flex items-center justify-between"> - <strong className="font-medium text-gray-900">{comment.author}</strong> - <span className="text-sm text-gray-500"> - {new Date(comment._creationTime).toLocaleDateString()} - </span> - </header> - <main className="leading-relaxed text-gray-700"> - <p className="whitespace-pre-line">{comment.content}</p> - </main> - </article> - ))} + {comments.map(renderComment)} </div> ); });
| export const create = mutation({ | ||
| args: { | ||
| author: v.string(), | ||
| content: v.string(), | ||
| }, | ||
| handler: async (ctx, args) => { | ||
| await ctx.db.insert("comments", { | ||
| author: args.author, | ||
| content: args.content, | ||
| }); | ||
| }, | ||
| }); | ||
|
|
||
| export const list = query({ | ||
| handler: async (ctx) => { | ||
| return await ctx.db.query("comments").order("desc").collect(); | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
fd comments.ts --type fRepository: AmanVarshney01/create-better-t-stack
Length of output: 111
🏁 Script executed:
cat -n convex-astro/convex/comments.tsRepository: AmanVarshney01/create-better-t-stack
Length of output: 700
🌐 Web query:
Convex db.insert return type validator
💡 Result:
Short answer: db.insert returns the new document's ID, and you validate that return with a function-level return validator (e.g. returns: v.id("tableName")). Use the validator builder from convex/values (v) so the function will throw at runtime if the handler returns a value that doesn't match the validator.
Example:
import { mutation } from "./_generated/server";
import { v } from "convex/values";
export const create = mutation({
args: { text: v.string() },
returns: v.id("tasks"),
handler: async (ctx, { text }) => {
return await ctx.db.insert("tasks", { text }); // insert returns the new Id
},
});
Docs: Convex return-value validators and db.insert behavior. [1][2][3]
Sources
[1] Convex — Argument and Return Value Validation.
[2] Convex — Announcing Convex 1.13 (return value validators).
[3] Convex — Writing Data (db.insert returns ID).
🌐 Web query:
Convex db.query collect return type validator
💡 Result:
Short answer: use a return-value validator on the query and specify an array validator (since collect() returns an array). Convex will validate at runtime and infer TypeScript types.
Example:
- Define the query with returns: v.array(...), then call .collect() on the returned Query in your handler or client.
Server-side example:
import { query } from "./_generated/server";
import { v } from "convex/values";
export const listMessages = query({
args: {},
returns: v.array(v.object({ _id: v.id("messages"), body: v.string(), author: v.string() })),
handler: async (ctx) => {
return await ctx.db.query("messages").collect();
},
});
Notes:
- collect() returns all results as an array, so use v.array(...) for the validator. [1][2]
- Return validators throw at runtime if the returned value doesn't match; validators also drive TypeScript inference (use Infer<> if needed). [1][3]
Sources:
- Convex argument & return value validators. [1]
- Query.collect() documentation. [2]
- Release notes introducing return value validators. [3]
Add return validators and args validator to Convex functions.
Both create and list are missing returns validators. list is also missing an args validator. Per repository guidelines, all Convex functions must include explicit argument and return validators.
Additionally, convert handlers from arrow functions to the standard function declaration syntax.
🛠️ Suggested fix
export const create = mutation({
args: {
author: v.string(),
content: v.string(),
},
- handler: async (ctx, args) => {
- await ctx.db.insert("comments", {
+ returns: v.id("comments"),
+ async handler(ctx, args) {
+ return await ctx.db.insert("comments", {
author: args.author,
content: args.content,
});
},
});
export const list = query({
- handler: async (ctx) => {
- return await ctx.db.query("comments").order("desc").collect();
+ args: {},
+ returns: v.array(
+ v.object({
+ _id: v.id("comments"),
+ _creationTime: v.number(),
+ author: v.string(),
+ content: v.string(),
+ }),
+ ),
+ async handler(ctx) {
+ return await ctx.db.query("comments").order("desc").collect();
},
});There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
apps/web/content/docs/guides/cloudflare-alchemy.mdx (1)
37-65: Update scaffold commands to usebunfor consistency with operational commands throughout the guide.Lines 40, 51, and 60 use
npm create better-t-stack@latest, but all subsequent operational commands (deploy, dev, destroy, db:push, build) usebun run(lines 230+). Users should either scaffold withbunx create better-t-stack@latestor the guide should clarify why npm is used only for scaffolding while bun is required for everything else.apps/cli/src/utils/compatibility-rules.ts (1)
36-39: Error message doesn't list Astro as a web framework option.The error message lists web frameworks but omits "astro" from the list.
📝 Proposed fix
if (web.length > 1) { exitWithError( - "Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router, next, nuxt, svelte, solid", + "Cannot select multiple web frameworks. Choose only one of: tanstack-router, tanstack-start, react-router, next, nuxt, svelte, solid, astro", ); }apps/web/content/docs/index.mdx (1)
93-93: Addastroto the--frontendoptions list.The Astro frontend was added in this PR but is missing from the documentation's flags cheat sheet.
📝 Proposed fix
-- `--frontend`: tanstack-router, react-router, tanstack-start, next, nuxt, svelte, solid, native-bare, native-uniwind, native-unistyles, none +- `--frontend`: tanstack-router, react-router, tanstack-start, next, nuxt, svelte, solid, astro, native-bare, native-uniwind, native-unistyles, none
♻️ Duplicate comments (1)
apps/web/content/docs/guides/cloudflare-alchemy.mdx (1)
511-511: Fix typo in heading ("Continous" → "Continuous").✏️ Proposed fix
-## Continous Integration +## Continuous Integration
🧹 Nitpick comments (1)
apps/cli/src/utils/compatibility-rules.ts (1)
335-337: Consider adding Astro to AI example validation for consistency.The
isExampleAIAllowedfunction correctly blocks Astro + AI, butvalidateExamplesCompatibilityonly has a specific error message for Solid + AI. For consistency, consider adding Astro here as well.📝 Proposed fix
- if (examplesArr.includes("ai") && (frontend ?? []).includes("solid")) { - exitWithError("The 'ai' example is not compatible with the Solid frontend."); + if (examplesArr.includes("ai") && (frontend ?? []).includes("solid")) { + exitWithError("The 'ai' example is not compatible with the Solid frontend."); + } + + if (examplesArr.includes("ai") && (frontend ?? []).includes("astro")) { + exitWithError("The 'ai' example is not compatible with the Astro frontend."); }
| } else if (frontend.includes("astro")) { | ||
| addPackageDependency({ | ||
| vfs, | ||
| packagePath: webPkgPath, | ||
| devDependencies: ["alchemy", "@cloudflare/workers-types"], | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's read the deploy-deps.ts file to understand the context
cat -n packages/template-generator/src/processors/deploy-deps.tsRepository: AmanVarshney01/create-better-t-stack
Length of output: 3127
🏁 Script executed:
# Search for Astro-related files and templates
find . -type f -name "*astro*" | head -20Repository: AmanVarshney01/create-better-t-stack
Length of output: 1132
🏁 Script executed:
# Search for `@astrojs/cloudflare` references
rg "@astrojs/cloudflare" --type ts --type tsx --type js --type jsonRepository: AmanVarshney01/create-better-t-stack
Length of output: 107
🏁 Script executed:
# Search for astro in package.json files
rg "astro" packages/ -t json | head -20Repository: AmanVarshney01/create-better-t-stack
Length of output: 62
🏁 Script executed:
# Check if there are template files that might add Astro deps
find . -path "*/templates/*" -type f | grep -i astro | head -10Repository: AmanVarshney01/create-better-t-stack
Length of output: 1037
🌐 Web query:
Astro Cloudflare adapter @astrojs/cloudflare required dependencies wrangler
💡 Result:
Short answer: to use the Astro Cloudflare adapter (@astrojs/cloudflare) you need the adapter itself plus the Cloudflare Wrangler CLI (installed as a dev dependency). Install commands shown in the docs:
- Adapter: npm install
@astrojs/cloudflare. [1][2] - Wrangler CLI: npm install wrangler@latest --save-dev (or pnpm add wrangler --save-dev). [1][3]
Notes: Astro’s npx astro add cloudflare will add the adapter and create a wrangler.jsonc for you; a Wrangler config file is optional for simple projects (Astro can generate defaults). [1][2]
Sources:
[1] Astro deploy → Cloudflare (docs).
[2] @astrojs/cloudflare integration (Astro docs).
[3] Cloudflare Pages + Astro (Cloudflare docs).
Add missing Astro Cloudflare adapter and wrangler dependencies.
The Astro Cloudflare branch only adds alchemy and @cloudflare/workers-types, but according to Astro documentation, deploying to Cloudflare requires the @astrojs/cloudflare adapter and wrangler for local development. All other frameworks in this file (Next, Nuxt, Svelte, TanStack Start) include their respective framework adapters. Add both to maintain consistency and ensure Cloudflare builds succeed:
Fix
- devDependencies: ["alchemy", "@cloudflare/workers-types"],
+ devDependencies: ["alchemy", "@cloudflare/workers-types", "wrangler", "@astrojs/cloudflare"],There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
apps/web/src/app/(home)/new/_components/utils.ts (3)
97-102: Message doesn't reflect that Astro is also removed.The condition and filter now handle both Solid and Astro, but the message on line 101 only mentions Solid. When Astro is removed, users would see a misleading message.
Proposed fix
// Remove incompatible frontends if (nextStack.webFrontend.includes("solid") || nextStack.webFrontend.includes("astro")) { + const removedFrontends: string[] = []; + if (nextStack.webFrontend.includes("solid")) removedFrontends.push("Solid"); + if (nextStack.webFrontend.includes("astro")) removedFrontends.push("Astro"); nextStack.webFrontend = nextStack.webFrontend.filter((f) => f !== "solid" && f !== "astro"); if (nextStack.webFrontend.length === 0) nextStack.webFrontend = ["none"]; changed = true; - changes.push({ category: "backend", message: "Removed Solid (incompatible with Convex)" }); + changes.push({ category: "backend", message: `Removed ${removedFrontends.join(" and ")} (incompatible with Convex)` }); }
943-951: Missing Astro in tRPC disabled reason check.The
analyzeStackCompatibilityfunction (line 494) includes"astro"in the frontends requiring oRPC, but thisgetDisabledReasoncheck at line 944 does not include it. This inconsistency means tRPC won't appear disabled in the UI when Astro is selected, even though it will be auto-corrected.Proposed fix
if (category === "api" && optionId === "trpc") { - const needsOrpc = currentStack.webFrontend.some((f) => ["nuxt", "svelte", "solid"].includes(f)); + const needsOrpc = currentStack.webFrontend.some((f) => ["nuxt", "svelte", "solid", "astro"].includes(f)); if (needsOrpc) { const frontendName = currentStack.webFrontend.find((f) => - ["nuxt", "svelte", "solid"].includes(f), + ["nuxt", "svelte", "solid", "astro"].includes(f), ); return `${frontendName} requires oRPC, not tRPC`; } }
26-32: Add Astro to PWA and Tauri compatible frontend lists.Astro is currently excluded from both
hasPWACompatibleFrontendandhasTauriCompatibleFrontend, but the codebase already supports Astro as a first-class fullstack framework (viaself-astrobackend). Astro has official PWA support via the@vite-pwa/astrointegration and supports Tauri integration through standard build configuration. Both functions should include"astro"in their framework checks to match the broader framework support in this scaffolding tool.Additionally, line 944 has an inconsistency where
"astro"is missing from theneedsOrpccheck—it should be added alongside the other non-React frameworks that require oRPC.
♻️ Duplicate comments (1)
packages/template-generator/src/processors/deploy-deps.ts (1)
64-69: Addwranglerfor Astro Cloudflare deploys.The Astro Cloudflare branch still omits
wrangler, which other Cloudflare frontends include and is typically needed for local dev/preview workflows. Consider adding it unless intentionally excluded.✅ Proposed fix
- devDependencies: ["alchemy", "@astrojs/cloudflare", "@cloudflare/workers-types"], + devDependencies: ["alchemy", "@astrojs/cloudflare", "@cloudflare/workers-types", "wrangler"],Does Astro’s Cloudflare adapter require the wrangler CLI as a devDependency for local development/preview?
🧹 Nitpick comments (1)
apps/web/src/app/(home)/_components/FeatureCard.tsx (1)
37-45: Consider aligning the light-theme icon list with other components.The addition of
"astro"is correct. However, this component's light-theme icon list (drizzle,prisma,express,astro) is missing some entries present in similar components liketech-icon.tsxandtech-badge.tsx(clerk,planetscale,polar).This may be intentional if those icons aren't used in
FeatureCard, but worth verifying for consistency.#!/bin/bash # Check which icons are actually used in FeatureCard contexts to verify if clerk/planetscale/polar are needed rg -n "FeatureCard" --type=tsx -A 10 | head -100
Summary by CodeRabbit
New Features
Documentation
UI
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.