-
-
Notifications
You must be signed in to change notification settings - Fork 180
fix: modernize partner integration add-ons #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@tanstack/create': patch | ||
| --- | ||
|
|
||
| Modernize the Clerk and WorkOS add-ons with their full-stack TanStack Start SDKs, | ||
| update Railway projects for Railpack, and use safer Sentry defaults. Secret | ||
| environment values are no longer stored in `.cta.json` or overwritten by | ||
| `tanstack add`, and pnpm 11 projects receive the build approvals their selected | ||
| integrations require. |
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
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
58 changes: 32 additions & 26 deletions
58
packages/create/src/frameworks/react/add-ons/clerk/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,50 @@ | ||
| ## Setting up Clerk | ||
|
|
||
| 1. Sign up at [clerk.com](https://clerk.com) and create an application | ||
| 2. Copy the **Publishable Key** from the Clerk dashboard | ||
| 3. Set it in your `.env.local`: | ||
| 1. Create an application in the [Clerk dashboard](https://dashboard.clerk.com). | ||
| 2. Copy its publishable and secret keys into `.env.local`: | ||
|
|
||
| ```bash | ||
| VITE_CLERK_PUBLISHABLE_KEY=pk_test_... | ||
| CLERK_SECRET_KEY=sk_test_... | ||
| ``` | ||
| 4. Visit the demo route at `/demo/clerk` once `npm run dev` is running | ||
|
|
||
| 3. Start the app and visit `/demo/clerk`. | ||
|
|
||
| ### What's wired up | ||
|
|
||
| - **`<ClerkProvider>`** at the app root (`src/integrations/clerk/provider.tsx`) handles auth context for the whole tree | ||
| - **`<SignInButton>` / `<UserButton>`** in the header swap based on auth state | ||
| - **`/demo/clerk`** shows Clerk's prebuilt sign-in UI and a signed-in greeting | ||
| - `clerkMiddleware()` authenticates each server request from `src/start.ts`. | ||
| - `<ClerkProvider>` supplies auth state throughout the app. | ||
| - `<SignInButton>` and `<UserButton>` in the header respond to the session. | ||
| - `/demo/clerk` shows Clerk's prebuilt sign-in UI and signed-in user data. | ||
|
|
||
| ### Protecting a route | ||
|
|
||
| Wrap any component in `<SignedIn>` / `<SignedOut>`: | ||
| Use `auth()` in a loader or server function when authorization must happen on the | ||
| server: | ||
|
|
||
| ```tsx | ||
| import { SignedIn, SignedOut, RedirectToSignIn } from '@clerk/clerk-react' | ||
|
|
||
| function ProtectedPage() { | ||
| return ( | ||
| <> | ||
| <SignedIn> | ||
| <YourPageContent /> | ||
| </SignedIn> | ||
| <SignedOut> | ||
| <RedirectToSignIn /> | ||
| </SignedOut> | ||
| </> | ||
| ) | ||
| } | ||
| import { createFileRoute, redirect } from '@tanstack/react-router' | ||
| import { createServerFn } from '@tanstack/react-start' | ||
| import { auth } from '@clerk/tanstack-react-start/server' | ||
|
|
||
| const getAuth = createServerFn({ method: 'GET' }).handler(async () => { | ||
| const { userId } = await auth() | ||
| return { userId } | ||
| }) | ||
|
|
||
| export const Route = createFileRoute('/dashboard')({ | ||
| beforeLoad: async () => { | ||
| const { userId } = await getAuth() | ||
| if (!userId) throw redirect({ to: '/' }) | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| For server-side checks (route loaders, server functions), see the Clerk docs on [`auth()`](https://clerk.com/docs/references/backend/auth). | ||
| `<Show when="signed-in">` remains useful for presentation, but server-side checks | ||
| are the security boundary. See Clerk's [TanStack Start docs](https://clerk.com/docs/tanstack-react-start/getting-started/quickstart). | ||
|
|
||
| ### Production checklist | ||
|
|
||
| - Replace the test keys with **production keys** from a dedicated production Clerk instance | ||
| - Configure your production domain under **Domains** in the Clerk dashboard | ||
| - Set up social providers (Google, GitHub, etc.) under **User & Authentication → Social Connections** | ||
| - Set both keys in the production environment; never expose `CLERK_SECRET_KEY`. | ||
| - Use production keys from a dedicated production Clerk instance. | ||
| - Configure the production domain and any social connections in the Clerk dashboard. | ||
3 changes: 2 additions & 1 deletion
3
packages/create/src/frameworks/react/add-ons/clerk/assets/_dot_env.local.append
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # Clerk configuration, get this key from your [Dashboard](dashboard.clerk.com) | ||
| # Clerk configuration: https://dashboard.clerk.com/last-active?path=api-keys | ||
| VITE_CLERK_PUBLISHABLE_KEY= | ||
| CLERK_SECRET_KEY= |
15 changes: 5 additions & 10 deletions
15
...s/create/src/frameworks/react/add-ons/clerk/assets/src/integrations/clerk/header-user.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,14 @@ | ||
| import { | ||
| SignedIn, | ||
| SignInButton, | ||
| SignedOut, | ||
| UserButton, | ||
| } from '@clerk/clerk-react' | ||
| import { Show, SignInButton, UserButton } from '@clerk/tanstack-react-start' | ||
|
|
||
| export default function HeaderUser() { | ||
| return ( | ||
| <> | ||
| <SignedIn> | ||
| <Show when="signed-in"> | ||
| <UserButton /> | ||
| </SignedIn> | ||
| <SignedOut> | ||
| </Show> | ||
| <Show when="signed-out"> | ||
| <SignInButton /> | ||
| </SignedOut> | ||
| </Show> | ||
| </> | ||
| ) | ||
| } |
13 changes: 2 additions & 11 deletions
13
...ages/create/src/frameworks/react/add-ons/clerk/assets/src/integrations/clerk/provider.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,9 @@ | ||
| import { ClerkProvider } from '@clerk/clerk-react' | ||
|
|
||
| const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY | ||
| if (!PUBLISHABLE_KEY) { | ||
| throw new Error('Add your Clerk Publishable Key to the .env.local file') | ||
| } | ||
| import { ClerkProvider } from '@clerk/tanstack-react-start' | ||
|
|
||
| export default function AppClerkProvider({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode | ||
| }) { | ||
| return ( | ||
| <ClerkProvider publishableKey={PUBLISHABLE_KEY} afterSignOutUrl="/"> | ||
| {children} | ||
| </ClerkProvider> | ||
| ) | ||
| return <ClerkProvider>{children}</ClerkProvider> | ||
| } |
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
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
2 changes: 1 addition & 1 deletion
2
packages/create/src/frameworks/react/add-ons/clerk/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "dependencies": { | ||
| "@clerk/clerk-react": "^5.61.3" | ||
| "@clerk/tanstack-react-start": "^1.4.21" | ||
| } | ||
| } |
14 changes: 7 additions & 7 deletions
14
packages/create/src/frameworks/react/add-ons/sentry/assets/instrument.server.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| import * as Sentry from '@sentry/tanstackstart-react' | ||
|
|
||
| const sentryDsn = import.meta.env?.VITE_SENTRY_DSN ?? process.env.VITE_SENTRY_DSN | ||
| const sentryDsn = | ||
| import.meta.env?.VITE_SENTRY_DSN ?? process.env.VITE_SENTRY_DSN | ||
|
|
||
| if (!sentryDsn) { | ||
| console.warn('VITE_SENTRY_DSN is not defined. Sentry is not running.') | ||
| } else { | ||
| Sentry.init({ | ||
| dsn: sentryDsn, | ||
| // Adds request headers and IP for users, for more info visit: | ||
| // https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/configuration/options/#sendDefaultPii | ||
| sendDefaultPii: true, | ||
| tracesSampleRate: 1.0, | ||
| replaysSessionSampleRate: 1.0, | ||
| replaysOnErrorSampleRate: 1.0, | ||
| dataCollection: { | ||
| userInfo: false, | ||
| httpBodies: [], | ||
| }, | ||
| tracesSampleRate: 0.1, | ||
| }) | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.