API
When you create a new Better Auth instance, you get an object called api
with a set of functions that you can use to interact with the server.
Any endpoint added on the server will be available on the api
object.
Calling API on the Server
Better auth uses a library called better-call to make API endpoints. It's a library made by the same team behind Better Auth and is designed to work seamlessly with it.Better call endpoints allow you to call rest
api handlers as if they were normal functions.
Example: Getting the current Session In Next JS
Unlike the client, the server needs the values to be passed as an object with the key body
for the body, headers
for the headers, and query
for the query.