Skip to content

Commit cadd476

Browse files
NicolappsConvex, Inc.
authored andcommitted
Support TanStack Start for WorkOS auto-provision (#42465)
GitOrigin-RevId: 4c5b9cea309a7bf0a1400ed70ab9f69df95840cc
1 parent f6b2213 commit cadd476

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

npm-packages/convex/src/cli/lib/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,12 @@ export async function handlePushConfigError(
11271127
const autoProvisionIfWorkOSTeamAssociated = !!(
11281128
homepage &&
11291129
[
1130+
// FIXME: We don’t want to rely on `homepage` from `package.json` for this
1131+
// because it’s brittle, and because AuthKit templates are now in get-convex/templates
11301132
"https://github.com/workos/template-convex-nextjs-authkit/#readme",
11311133
"https://github.com/workos/template-convex-react-vite-authkit/#readme",
11321134
"https://github.com:workos/template-convex-react-vite-authkit/#readme",
1135+
"https://github.com/workos/template-convex-tanstack-start-authkit/#readme",
11331136
].includes(homepage)
11341137
);
11351138
// Initially only specific templates offer team creation.

npm-packages/convex/src/cli/lib/workos/workos.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ async function updateEnvLocal(
292292
await suggestedEnvVarName(ctx);
293293

294294
// For now don't attempt for anything other than Vite or Next.js.
295-
if (!detectedFramework || !["Vite", "Next.js"].includes(detectedFramework)) {
295+
if (
296+
!detectedFramework ||
297+
!["Vite", "Next.js", "TanStackStart"].includes(detectedFramework)
298+
) {
296299
logWarning(
297300
"Can't configure .env.local, fill it out according to directions for the corresponding AuthKit SDK. Use `npx convex list` to see relevant environment variables.",
298301
);
@@ -317,22 +320,32 @@ async function updateEnvLocal(
317320
value: clientId,
318321
commentOnPreviousLine: `# See this environment at ${workosUrl(environmentId, "/authentication")}`,
319322
};
320-
} else if (detectedFramework === "Next.js") {
321-
// Next doesn't need the clint id to be public
323+
} else if (
324+
detectedFramework === "Next.js" ||
325+
detectedFramework === "TanStackStart"
326+
) {
327+
// Next/TanStack Start don’t need the client id to be public
322328
suggestedChanges[`WORKOS_CLIENT_ID`] = {
323329
value: clientId,
324330
commentOnPreviousLine: `# See this environment at ${workosUrl(environmentId, "/authentication")}`,
325331
};
326332
}
327333

328334
if (frontendDevUrl) {
329-
suggestedChanges[`${publicPrefix}WORKOS_REDIRECT_URI`] = {
335+
suggestedChanges[
336+
detectedFramework === "TanStackStart"
337+
? "WORKOS_REDIRECT_URI"
338+
: `${publicPrefix}WORKOS_REDIRECT_URI`
339+
] = {
330340
value: `${frontendDevUrl}/callback`,
331341
};
332342
}
333343
}
334344

335-
if (detectedFramework === "Next.js") {
345+
if (
346+
detectedFramework === "Next.js" ||
347+
detectedFramework === "TanStackStart"
348+
) {
336349
if (
337350
!existingFileContent ||
338351
!existingFileContent.includes("WORKOS_COOKIE_PASSWORD")

0 commit comments

Comments
 (0)