Latest Node.js SDK version - 
The Crossmint server SDK (@crossmint/server-sdk) provides a set of tools for authenticating users in a Crossmint-powered application using server-side rendering (SSR). It simplifies the process of handling authentication tokens and managing user sessions, making it easier to integrate authentication into your Next.js applications.
Installation
To install the SDK, you can use npm or yarn:Usage
To use the SDK in your application, follow these steps:- Import the SDK into your project:
- Use the SDK to authenticate users:
getSession method:
- Store the authentication material in cookies
getSession method:
- Logout
Security
The SDK allows you to set thehttpOnly, secure, domain and sameSite options for the cookies. This way, you can control how the cookies are stored and transmitted. Putting this together with a custom refresh route, you can store the authentication material in HttpOnly cookies that are tied to the domain of the provided route.
Configure CrossmintAuth to do so when creating the custom refresh route:
httpOnly only applies to the refresh token. The session token will not be HttpOnly as it is used in the client for API calls.
Set up a custom refresh route
To set up a custom refresh route, you can use thehandleCustomRefresh method. This method will refresh the token and return the new authentication material. This way, the authentication material can be stored in cookies that are tied to the domain of the provided route.
In environments that use the Fetch API for Request and Response objects, handleCustomRefresh will return the response object:
Using a custom refresh route
You can also provide a custom refresh route:Set up a custom logout route
When usingHttpOnly cookies, logout can’t happen client-side as it doesn’t have access to the cookies. You can set up a custom logout route to handle the logout process.
In environments that use the Fetch API, logout will return the response object:

