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

Simple .identify example for new context (context change) #3

Open
codyde opened this issue Jun 27, 2024 · 1 comment
Open

Simple .identify example for new context (context change) #3

codyde opened this issue Jun 27, 2024 · 1 comment

Comments

@codyde
Copy link
Contributor

codyde commented Jun 27, 2024

I tried to write this up real quick, but I couldnt' figure out how to expose the .identify method from the client side launchdarkly client.

I think we should show a "Login button" example in the client component that when a user "clicks" - it changes the context from the default anonymous one, and updates the context in the cookie. We would then show how the new context is passed to the server side via cookies as well, creating a consistent login.

I tried to do this in this PR - #2, but ultimately removed the code because I couldn't get it working quite right.

@yusinto
Copy link
Collaborator

yusinto commented Jun 27, 2024

I think you're right we should support identify. In a Client Component, we can cast the ldClient returned from useLDClient as JSSdk and call the identify function onButtonClick. That should do it. This code should work with ssr because the button click event will not be called on server render. It will only execute on the browser. I'll try do it in js-core tomorrow.

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

No branches or pull requests

2 participants