Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix: cache is not exportet from react (#417)

Meier Lukasfba767bde3d1
diff --git a/apps/nextjs/src/app/[locale]/layout.tsx b/apps/nextjs/src/app/[locale]/layout.tsx
index 071d1dc71..379289f56 100644
--- a/apps/nextjs/src/app/[locale]/layout.tsx
+++ b/apps/nextjs/src/app/[locale]/layout.tsx
@@ -7,7 +7,7 @@ import "@mantine/core/styles.css";
import { ColorSchemeScript, createTheme, MantineProvider } from "@mantine/core";
-import { auth } from "@homarr/auth";
+import { auth } from "@homarr/auth/next";
import { ModalProvider } from "@homarr/modals";
import { Notifications } from "@homarr/notifications";
diff --git a/apps/nextjs/src/app/api/trpc/[trpc]/route.ts b/apps/nextjs/src/app/api/trpc/[trpc]/route.ts
index 74ff0f7d9..e4682239b 100644
--- a/apps/nextjs/src/app/api/trpc/[trpc]/route.ts
+++ b/apps/nextjs/src/app/api/trpc/[trpc]/route.ts
@@ -1,7 +1,7 @@
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { appRouter, createTRPCContext } from "@homarr/api";
-import { auth } from "@homarr/auth";
+import { auth } from "@homarr/auth/next";
import { logger } from "@homarr/log";
/**
diff --git a/apps/nextjs/src/components/board/permissions/server.ts b/apps/nextjs/src/components/board/permissions/server.ts
index b36b7c693..36fd6a6b7 100644
--- a/apps/nextjs/src/components/board/permissions/server.ts
+++ b/apps/nextjs/src/components/board/permissions/server.ts
@@ -1,4 +1,4 @@
-import { auth } from "@homarr/auth";
+import { auth } from "@homarr/auth/next";
import type { BoardPermissionsProps } from "@homarr/auth/shared";
import { constructBoardPermissions } from "@homarr/auth/shared";
diff --git a/apps/nextjs/src/components/user-avatar.tsx b/apps/nextjs/src/components/user-avatar.tsx
index 76a4025f1..dd30dc647 100644
--- a/apps/nextjs/src/components/user-avatar.tsx
+++ b/apps/nextjs/src/components/user-avatar.tsx
@@ -1,7 +1,7 @@
import type { AvatarProps, MantineSize } from "@mantine/core";
import { Avatar } from "@mantine/core";
-import { auth } from "@homarr/auth";
+import { auth } from "@homarr/auth/next";
interface UserAvatarProps {
size: MantineSize;
diff --git a/packages/api/src/server.ts b/packages/api/src/server.ts
index e014de061..c7522c0af 100644
--- a/packages/api/src/server.ts
+++ b/packages/api/src/server.ts
@@ -2,7 +2,7 @@ import { cache } from "react";
import { headers } from "next/headers";
import { createCaller, createTRPCContext } from "@homarr/api";
-import { auth } from "@homarr/auth";
+import { auth } from "@homarr/auth/next";
/**
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
diff --git a/packages/auth/index.ts b/packages/auth/index.ts
index 3495d19ed..687689695 100644
--- a/packages/auth/index.ts
+++ b/packages/auth/index.ts
@@ -1,4 +1,3 @@
-import { cache } from "react";
import type { DefaultSession } from "@auth/core/types";
import { createConfiguration } from "./configuration";
@@ -17,11 +16,5 @@ export * from "./security";
export const createHandlers = (isCredentialsRequest: boolean) =>
createConfiguration(isCredentialsRequest);
-const { auth: defaultAuth } = createConfiguration(false);
-/**
- * This is the main way to get session data for your RSCs.
- * This will de-duplicate all calls to next-auth's default `auth()` function and only call it once per request
- */
-export const auth = cache(defaultAuth);
export { getSessionFromToken, sessionTokenCookieName } from "./session";
diff --git a/packages/auth/next.ts b/packages/auth/next.ts
new file mode 100644
index 000000000..77b178d13
--- /dev/null
+++ b/packages/auth/next.ts
@@ -0,0 +1,11 @@
+import { cache } from "react";
+
+import { createConfiguration } from "./configuration";
+
+const { auth: defaultAuth } = createConfiguration(false);
+
+/**
+ * This is the main way to get session data for your RSCs.
+ * This will de-duplicate all calls to next-auth's default `auth()` function and only call it once per request
+ */
+export const auth = cache(defaultAuth);
diff --git a/packages/auth/package.json b/packages/auth/package.json
index 59c1bae35..de77e8516 100644
--- a/packages/auth/package.json
+++ b/packages/auth/package.json
@@ -4,6 +4,7 @@
"type": "module",
"exports": {
".": "./index.ts",
+ "./next": "./next.ts",
"./security": "./security.ts",
"./client": "./client.ts",
"./shared": "./shared.ts",