logto-io / js

🤓 Logto JS SDKs.
https://docs.logto.io/quick-starts/
MIT License
61 stars 40 forks source link

feature request: How to set the directSignIn property in the singin function Using useLogto #777

Closed soralee closed 1 month ago

soralee commented 1 month ago

What problem did you meet?

I am using the useLogto hook in my React application and I would like to know if it is possible to set the signIn function to enable the directSignIn property.

Describe what you'd like Logto to have

Could you please provide guidance or an example on how to achieve this?

darcyYe commented 1 month ago

You can take a look on our direct sign-in docs to see if it can help. We currently do not have a guide for direct sign-in, but we are going to work on providing guide and update SDK to boost developers experience.

charIeszhao commented 1 month ago

If you are using React SDK, try this;

const { signIn } = useLogto();

<button
  type="button"
  onClick={() => {
    void signIn({
      redirectUri: 'http://your.redirect.uri',
      directSignIn: { method: 'social', target: 'google' },
    });
  }}
>
  Sign in
</button>
soralee commented 1 month ago

Thanks for all the replies. I realized the issue was a TypeScript error on my part, and updating to version 3.0.14 resolved it.

I'll close this now.

Thanks again for all the help!