Skip to content
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

feat(clerk-js): Lazy load Sign up on Combined flow #5237

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Feb 26, 2025

Description

Lazy load parts of sign up inside sign in when only when needed by combined flow. Ensures that only one chunk for sign up will be created.

Before After
bundles
Screenshot 2025-02-26 at 3 31 30 PM Screenshot 2025-02-26 at 3 26 02 PM
Plain SignIn
Screenshot 2025-02-26 at 3 40 51 PM Screenshot 2025-02-26 at 3 43 40 PM
Plain SignUp
Screenshot 2025-02-26 at 3 44 30 PM Screenshot 2025-02-26 at 3 43 55 PM
SignIn combined flow
Screenshot 2025-02-26 at 3 48 17 PM
SignIn /create
Screenshot 2025-02-26 at 3 49 16 PM Screenshot 2025-02-26 at 3 47 50 PM

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@panteliselef panteliselef requested a review from a team February 26, 2025 13:30
@panteliselef panteliselef self-assigned this Feb 26, 2025
Copy link

changeset-bot bot commented Feb 26, 2025

🦋 Changeset detected

Latest commit: d701f0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 0:13am

@panteliselef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @panteliselef - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.4-snapshot.v20250226133227
@clerk/astro 2.3.0-snapshot.v20250226133227
@clerk/backend 1.24.3-snapshot.v20250226133227
@clerk/chrome-extension 2.2.11-snapshot.v20250226133227
@clerk/clerk-js 5.54.0-snapshot.v20250226133227
@clerk/elements 0.23.0-snapshot.v20250226133227
@clerk/clerk-expo 2.8.0-snapshot.v20250226133227
@clerk/expo-passkeys 0.1.22-snapshot.v20250226133227
@clerk/express 1.3.50-snapshot.v20250226133227
@clerk/fastify 2.1.23-snapshot.v20250226133227
@clerk/localizations 3.10.8-snapshot.v20250226133227
@clerk/nextjs 6.12.1-snapshot.v20250226133227
@clerk/nuxt 1.2.1-snapshot.v20250226133227
@clerk/clerk-react 5.24.0-snapshot.v20250226133227
@clerk/react-router 1.1.1-snapshot.v20250226133227
@clerk/remix 4.5.1-snapshot.v20250226133227
@clerk/shared 3.0.0-snapshot.v20250226133227
@clerk/tanstack-start 0.11.0-snapshot.v20250226133227
@clerk/testing 1.4.24-snapshot.v20250226133227
@clerk/themes 2.2.20-snapshot.v20250226133227
@clerk/types 4.47.0-snapshot.v20250226133227
@clerk/ui 0.3.25-snapshot.v20250226133227
@clerk/vue 1.3.0-snapshot.v20250226133227

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/ui

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@panteliselef panteliselef marked this pull request as ready for review February 26, 2025 14:00
Copy link
Member

@dstaley dstaley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I think this is fine, but we really need to figure out what changes are necessary to get proper component-sharing working with our router. We should be able to simply create a shared component containing these routes and share that between <SignIn> and <SignUp>, with the former loading the component through a lazy() boundary.

Comment on lines +106 to +107
const isCacheStale =
typeof getCache()?.cachedAt === 'undefined' ? true : Date.now() - (getCache()?.cachedAt || 0) >= staleTime;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this change doing here? 👀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the current behaviour a bit buggy, when I added

const usePreloadSignUp = (enabled = false) =>
  useFetch(enabled ? preloadSignUp : undefined, 'preloadComponent', { staleTime: Infinity });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants