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

Introduce force-an-org example with clerk-js custom flow #25

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Apr 4, 2025

Resolves ORGS-602

Introduces example of how to build custom flows with force-an-org enabled using pure clerk-js

@LauraBeatris LauraBeatris self-assigned this Apr 4, 2025
@LauraBeatris LauraBeatris force-pushed the laura/force-an-org-vanilla-js branch 4 times, most recently from e4f1c9e to 7ac9178 Compare April 4, 2025 11:24
@LauraBeatris LauraBeatris force-pushed the laura/force-an-org-vanilla-js branch 9 times, most recently from 529435c to 45ed87b Compare April 4, 2025 16:43
@LauraBeatris LauraBeatris force-pushed the laura/force-an-org-vanilla-js branch from 45ed87b to f72d0b9 Compare April 4, 2025 17:04

// Check for any pending tasks (like organization creation) and display the corresponding UI element
async function displayNextTaskIfAny() {
const task = clerk.currentTask;
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 think this should be abstracted into a method. Something like clerk.getCurrentTask().

If in the future, we want to abstract the logic of ordering tasks by priority, the SDK could handle this based on the task metadata so that the developer wouldn't have to manually orchestrate it.

};

// Here we're toggling UI visibility, but you could also navigate to different pages
// with `Clerk.__experimental_nextTask({ redirectUrlComplete })`
Copy link
Member Author

@LauraBeatris LauraBeatris Apr 4, 2025

Choose a reason for hiding this comment

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

🤔 Considering deprecating nextTask in favor of navigateToTask to be super explicit about it's intent.

The main goal of this method is to abstract the logic of navigation from a pending to an active transition. The SDK has to deal with a lot of internal complexity on behalf of the developer, such as setting a transitive state for accessors and doing the actual status transition check.


// Now that the user is created, set the session to active.
// TODO: Update this with clerk.setCurrentSession(signUpAttempt.createdSessionId)
await clerk.setActive({ session: signUpAttempt.createdSessionId });
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ setActive needs to be deprecated in favor of the current nomenclature. It's on my list to work once I'm back from vacation.

@LauraBeatris LauraBeatris changed the title Introduce force-an-org example with custom flows and pure clerk-js Introduce force-an-org example with custom flow and pure clerk-js Apr 4, 2025
@LauraBeatris LauraBeatris changed the title Introduce force-an-org example with custom flow and pure clerk-js Introduce force-an-org example with custom flow and clerk-js Apr 4, 2025
@LauraBeatris LauraBeatris changed the title Introduce force-an-org example with custom flow and clerk-js Introduce force-an-org example with clerk-js custom flow Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant