<@U04UQ68083H> how can I use the javascript sdk to...
# ory-copilot
t
@chilly-king-10285 how can I use the javascript sdk to create a recovery link for a user?
c
A message from kapa.ai
To create a recovery link for a user using the JavaScript SDK, you can use the
FrontendApi
class from the
@ory/client
package. Here is a sample code snippet:
Copy code
javascript import { Configuration, FrontendApi } from "@ory/client"  const frontend = new FrontendApi(   new Configuration({     basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`,   }), )  export async function createRecovery() {   return await frontend.createNativeRecoveryFlow() }
This function
createRecovery
will create a recovery flow for a user. Please note that you need to replace
${process.env.ORY_PROJECT_SLUG}
with your actual project slug. This code snippet is a part of the Ory Kratos JavaScript SDK. It's important to note that this function will only initiate the recovery flow. To actually create a recovery link, you would need to interact with the
createRecoveryLinkForIdentity
endpoint of the Ory Kratos Admin API, which is not directly available in the JavaScript SDK. For more details, you can refer to the [Ory Kratos API Reference](https://www.ory.sh/docs/kratos/reference/api) and [Ory Kratos JavaScript SDK documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#create-recovery-flow).