1.0.2 • Published 8 months ago

@crossmint/server-sdk v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@crossmint/server-sdk

This 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:

npm install @crossmint/server-sdk

Usage

To use the SDK in your application, follow these steps:

  1. Import the SDK into your project:
import { createCrossmint, CrossmintAuth } from "@crossmint/server-sdk";

const crossmint = createCrossmint({
    apiKey: process.env.SERVER_CROSSMINT_API_KEY || "",
});

const crossmintAuth = CrossmintAuth.from(crossmint);
  1. Use the SDK to authenticate users:

With most frameworks, pass the request object:

const { jwt, userId } = await crossmintAuth.getSession(request);

With Next.js, fetch the cookies and pass them to the getSession method:

import { cookies } from "next/headers";

const cookieStore = cookies();
const jwtCookie = cookieStore.get("crossmint-session")?.value;
const refreshCookie = cookieStore.get("crossmint-refresh-token")?.value;

const { jwt, userId } = await crossmintAuth.getSession({
    jwt: jwtCookie,
    refreshToken: refreshCookie,
});
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.3.0

8 months ago

0.2.0

8 months ago