← All packages

@lacspace/next

v1.1.3Core1 @lacspace dep

Next.js App Router integration for the Lacspace SDK — authenticated server client from cookies, Route Handler & Server Action wrappers, cookie helpers and a middleware auth guard.

npm i @lacspace/next

Usage

next.ts
import { createServerClient } from "@lacspace/next";

export default async function DashboardPage() {
  const lac = await createServerClient({ baseURL: "https://api.lacspace.com/api" });
  const products = await lac.ecommerce.getProducts(); // token applied from the cookie
  return <ProductGrid products={products} />;
}

Exports 12

authGuardclearAuthCookiecreateServerClientgetAuthTokengetCsrfTokenrouteHandlerserverActionClientsetAuthCookiesetCsrfCookieverifyCsrfwithAuthwithCsrf

Keywords

nextjsnextapp-routerserver-componentsserver-actionsmiddleware

More in Core