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

Headless error - loaded without UI components #1919

Closed
4 tasks done
targetlucked69 opened this issue Oct 19, 2023 · 5 comments
Closed
4 tasks done

Headless error - loaded without UI components #1919

targetlucked69 opened this issue Oct 19, 2023 · 5 comments

Comments

@targetlucked69
Copy link

Preliminary Checks

Reproduction / Replay Link

https://stackblitz.com/edit/vitejs-vite-1h7w8x

Publishable key

pk_test_Z29yZ2VvdXMtZmluY2gtMjQuY2xlcmsuYWNjb3VudHMuZGV2JA

Description

I'm trying to use Clerk with a vanilla Vite project and decided to go with the headless version since the normal one's build size is too big. Everything works until I use a method like openSignIn. I get the ClerkJS was loaded without UI components. error:

Screenshot 2023-10-18 at 10 58 33 PM

Steps to reproduce:

  1. Create a fresh vite project and choose vanilla.
  2. Initialize clerk and add a simple clerk.openSignIn() call.
  3. Check the console for the error.

Expected behavior:

It should open the signin popup, like what it does when using @clerk/clerk-js instead of @clerk/clerk-js/headless.

Actual behavior:

Popup not opening and is throwing an error.

How can I make sure that Clerk has been loaded with the UI components when using the headless version?

Environment

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 133.86 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/Library/Caches/fnm_multishells/76371_1697694026593/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.6.7 - ~/Library/Caches/fnm_multishells/76371_1697694026593/bin/npm
    pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
    Watchman: 2023.10.09.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 118.0.5993.70
    Safari: 17.0
  npmPackages:
    @clerk/clerk-js: ^4.62.1 => 4.62.1
    typescript: ^5.0.2 => 5.2.2
    vite: ^4.4.5 => 4.5.0
@targetlucked69 targetlucked69 added the needs-triage A ticket that needs to be triaged by a team member label Oct 19, 2023
@jescalan
Copy link
Contributor

In this case, you'd need to not use the headless version, as that version is shipped without UI components, hence the naming "headless". We do certainly need to add documentation on this though, we will get it on our list!

@LekoArts LekoArts added question and removed needs-triage A ticket that needs to be triaged by a team member labels Oct 19, 2023
@LekoArts
Copy link
Member

LekoArts commented Oct 19, 2023

Another thing to add (that is also missing from the docs, we'll work on it!) is that we'll only import the used components (not the full bundle). So tools that statically analyze packages can't know that.

@LekoArts LekoArts closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@targetlucked69
Copy link
Author

Thanks @jescalan and @LekoArts. I have another question if you don't mind.

  1. Is there a plan to ship the @clerk/clerk-js without the react dependency? Is that even possible since the components are made with React?
  2. If no. 1 is not an option, and I want to mount components in my vanilla javascript app, would using the CDN be a good alternative? What about the size of the CDN? Will it still have react bundled in it?

Thank you!

@jescalan
Copy link
Contributor

  1. As you noted, it's not possible, and would require us to kind of have an entirely different architecture for the way we set up the package. It's not out of the question in the future, but isn't currently high on the roadmap.
  2. It won't make any difference, the CDN houses the same package and does still have react bundled. In fact, our SDKs hot load clerk-js from the CDN as part of their own loading strategy.

@clerk-cookie
Copy link
Collaborator

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants