Skip to content

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

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_CLERK_PUBLISHABLE_KEY=abc
27 changes: 27 additions & 0 deletions examples/force-an-org-custom-flow-vanilla-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# local env files
.env
25 changes: 25 additions & 0 deletions examples/force-an-org-custom-flow-vanilla-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Force organization selection with `clerk-js`

This example shows how to build an application that does not allow users to operate under a _Personal Workspace_. To require organization membership for all users:
1. Navigate to **Organization Settings** page in the Clerk Dashboard
2. Enable the organizations feature if not already active
3. Turn on **Force organization selection**

## Set Up

Copy the `.env.example` file and update it with your Clerk application keys:

```
cp .env.example .env
```

## Getting Started

Install dependencies and run the development server:

```bash
pnpm i
pnpm dev
```

Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
54 changes: 54 additions & 0 deletions examples/force-an-org-custom-flow-vanilla-js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Force Organization Selection</title>
</head>

<body>
<div id="signed-in"></div>

<div id="sign-up">
<h2>Sign up</h2>
<form id="sign-up-form">
<label for="email">Enter email address</label>
<input type="email" name="email" id="sign-up-email" />
<label for="password">Enter password</label>
<input type="password" name="password" id="sign-up-password" />
<button type="submit">Continue</button>
</form>
</div>

<div id="sign-in">
<h2>Sign in</h2>
<form id="sign-in-form">
<label for="email">Enter email address</label>
<input name="email" id="sign-in-email" />
<label for="password">Enter password</label>
<input name="password" id="sign-in-password" />
<button type="submit">Continue</button>
</form>
</div>

<form id="verifying" hidden>
<h2>Verify your account</h2>
<label for="totp">Enter your code</label>
<input id="totp" name="code" />
<label for="backupCode">This code is a backup code</label>
<input type="checkbox" id="backupCode" name="backupCode" />
<button type="submit" id="verify-button">Verify</button>
</form>

<form id="create-organization" hidden>
<label for="name">Name</label>
<input id="name" name="name" />
<button>Create organization</button>
</form>

<script type="module" src="/src/main.js" async crossorigin="anonymous"></script>
</body>

</html>
14 changes: 14 additions & 0 deletions examples/force-an-org-custom-flow-vanilla-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "clerk-force-an-org",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^6.2.0"
}
}
Loading