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

@@ -1,7 +1,7 @@
import path from "node:path";
import fs from "fs-extra";
import type { ProjectConfig } from "../../types";
import { generateAuthSecret } from "../addons/auth-setup";
import { generateAuthSecret } from "./auth-setup";
export interface EnvVariable {
key: string;
@@ -143,6 +143,42 @@ export async function setupEnvironmentVariables(config: ProjectConfig) {
condition: true,
},
];
if (backend === "convex" && auth === "clerk") {
if (hasNextJs) {
clientVars.push(
{
key: "NEXT_PUBLIC_CLERK_FRONTEND_API_URL",
value: "",
condition: true,
},
{
key: "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
value: "",
condition: true,
},
{
key: "CLERK_SECRET_KEY",
value: "",
condition: true,
},
);
} else if (hasReactRouter || hasTanStackRouter || hasTanStackStart) {
clientVars.push({
key: "VITE_CLERK_PUBLISHABLE_KEY",
value: "",
condition: true,
});
if (hasTanStackStart) {
clientVars.push({
key: "CLERK_SECRET_KEY",
value: "",
condition: true,
});
}
}
}
await addEnvVariablesToFile(path.join(clientDir, ".env"), clientVars);
}
}
@@ -168,6 +204,14 @@ export async function setupEnvironmentVariables(config: ProjectConfig) {
condition: true,
},
];
if (backend === "convex" && auth === "clerk") {
nativeVars.push({
key: "EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY",
value: "",
condition: true,
});
}
await addEnvVariablesToFile(path.join(nativeDir, ".env"), nativeVars);
}
}