How do I create a plugin that adds a property to the client object?

Consider the magic-link plugin. When we register it, we get access to client.magicLink.verify(). How do I create my own plugin that does so? I read the source code of this plugin but didn't find anything useful. Thanks.
Solution:
magic-link -> magicLink, and verify is just verify, so together in the authClient it would be authClient.magicLink.verify
Jump to solution
6 Replies
Ping
Ping•2w ago
This is possible because of the $inferServerPlugin, which looks at all of the endpoints defined in the server plugin
No description
Mr. Mime
Mr. MimeOP•2w ago
But, the server just registered routes. Nowhere does it register .verify() method. @Ping
Ping
Ping•2w ago
It's inferred from the path
No description
Solution
Ping
Ping•2w ago
magic-link -> magicLink, and verify is just verify, so together in the authClient it would be authClient.magicLink.verify
Mr. Mime
Mr. MimeOP•2w ago
Oooo Cool Thanks 😊
Ping
Ping•2w ago
Sure, no worries

Did you find this page helpful?