feat: add clerk auth support with convex (#548)

This commit is contained in:
Aman Varshney
2025-08-29 00:21:08 +05:30
committed by GitHub
parent 8d48ae0359
commit 54bcdf1cbc
153 changed files with 1954 additions and 771 deletions

View File

@@ -157,7 +157,8 @@ function TechIcon({
theme === "light" &&
(icon.includes("drizzle") ||
icon.includes("prisma") ||
icon.includes("express"))
icon.includes("express") ||
icon.includes("clerk"))
) {
iconSrc = icon.replace(".svg", "-light.svg");
}
@@ -205,11 +206,24 @@ const analyzeStackCompatibility = (stack: StackState): CompatibilityResult => {
database: "none",
orm: "none",
api: "none",
auth: "false",
dbSetup: "none",
examples: ["todo"],
};
const hasClerkCompatibleFrontend =
nextStack.webFrontend.some((f) =>
["tanstack-router", "react-router", "tanstack-start", "next"].includes(
f,
),
) ||
nextStack.nativeFrontend.some((f) =>
["native-nativewind", "native-unistyles"].includes(f),
);
if (nextStack.auth !== "clerk" || !hasClerkCompatibleFrontend) {
convexOverrides.auth = "none";
}
for (const [key, value] of Object.entries(convexOverrides)) {
const catKey = key as keyof StackState;
if (JSON.stringify(nextStack[catKey]) !== JSON.stringify(value)) {
@@ -257,7 +271,7 @@ const analyzeStackCompatibility = (stack: StackState): CompatibilityResult => {
}
} else if (isBackendNone) {
const noneOverrides: Partial<StackState> = {
auth: "false",
auth: "none",
database: "none",
orm: "none",
api: "none",
@@ -336,20 +350,20 @@ const analyzeStackCompatibility = (stack: StackState): CompatibilityResult => {
message: "ORM set to 'None' (requires a database)",
});
}
if (nextStack.auth === "true") {
if (nextStack.auth !== "none" && nextStack.backend !== "convex") {
notes.database.notes.push(
"Database 'None' selected: Auth will be disabled.",
);
notes.auth.notes.push(
"Authentication requires a database. It will be disabled.",
"Authentication requires a database. It will be set to 'None'.",
);
notes.database.hasIssue = true;
notes.auth.hasIssue = true;
nextStack.auth = "false";
nextStack.auth = "none";
changed = true;
changes.push({
category: "database",
message: "Authentication disabled (requires a database)",
message: "Authentication set to 'None' (requires a database)",
});
}
if (nextStack.dbSetup !== "none") {
@@ -696,6 +710,7 @@ const analyzeStackCompatibility = (stack: StackState): CompatibilityResult => {
notes.runtime.hasIssue = true;
notes.dbSetup.hasIssue = true;
nextStack.dbSetup = "d1";
changed = true;
changes.push({
category: "runtime",
message:
@@ -725,6 +740,57 @@ const analyzeStackCompatibility = (stack: StackState): CompatibilityResult => {
});
}
if (nextStack.auth === "clerk") {
const hasClerkCompatibleFrontend =
nextStack.webFrontend.some((f) =>
[
"tanstack-router",
"react-router",
"tanstack-start",
"next",
].includes(f),
) ||
nextStack.nativeFrontend.some((f) =>
["native-nativewind", "native-unistyles"].includes(f),
);
if (!hasClerkCompatibleFrontend) {
notes.auth.notes.push(
"Clerk auth is not compatible with the selected frontends. Auth will be set to 'None'.",
);
notes.webFrontend.notes.push(
"Selected frontends are not compatible with Clerk auth. Auth will be disabled.",
);
notes.auth.hasIssue = true;
notes.webFrontend.hasIssue = true;
nextStack.auth = "none";
changed = true;
changes.push({
category: "auth",
message:
"Auth set to 'None' (Clerk not compatible with selected frontends)",
});
}
}
if (nextStack.backend === "convex" && nextStack.auth === "better-auth") {
notes.auth.notes.push(
"Better-Auth is not compatible with Convex backend. Auth will be set to 'None'.",
);
notes.backend.notes.push(
"Convex backend only supports Clerk auth or no auth. Auth will be disabled.",
);
notes.auth.hasIssue = true;
notes.backend.hasIssue = true;
nextStack.auth = "none";
changed = true;
changes.push({
category: "auth",
message:
"Auth set to 'None' (Better-Auth not compatible with Convex)",
});
}
const incompatibleAddons: string[] = [];
const isPWACompat = hasPWACompatibleFrontend(nextStack.webFrontend);
const isTauriCompat = hasTauriCompatibleFrontend(nextStack.webFrontend);
@@ -1120,9 +1186,7 @@ const generateCommand = (stackState: StackState): string => {
flags.push(`--orm ${stackState.orm}`);
}
if (!checkDefault("auth", stackState.auth)) {
if (stackState.auth === "false" && DEFAULT_STACK.auth === "true") {
flags.push("--no-auth");
}
flags.push(`--auth ${stackState.auth}`);
}
if (!checkDefault("dbSetup", stackState.dbSetup)) {
flags.push(`--db-setup ${stackState.dbSetup}`);
@@ -1527,16 +1591,12 @@ const StackBuilder = () => {
update[catKey] = techId;
} else {
if (
(category === "git" ||
category === "install" ||
category === "auth") &&
(category === "git" || category === "install") &&
techId === "false"
) {
update[catKey] = "true";
} else if (
(category === "git" ||
category === "install" ||
category === "auth") &&
(category === "git" || category === "install") &&
techId === "true"
) {
update[catKey] = "false";