From 6ded84c6de982db7710e719ed668f26b02954702 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 6 Apr 2026 15:54:50 +0200 Subject: [PATCH] fix(cms): extract serverFunction to separate 'use server' file for Next.js 15.5 server action registration --- apps/cms/src/app/(payload)/layout.tsx | 13 ++----------- apps/cms/src/app/(payload)/serverFunction.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 apps/cms/src/app/(payload)/serverFunction.ts diff --git a/apps/cms/src/app/(payload)/layout.tsx b/apps/cms/src/app/(payload)/layout.tsx index c78ffef..0eb1931 100644 --- a/apps/cms/src/app/(payload)/layout.tsx +++ b/apps/cms/src/app/(payload)/layout.tsx @@ -2,26 +2,17 @@ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ import config from "@payload-config"; import "@payloadcms/next/css"; -import type { ServerFunctionClient } from "payload"; -import { handleServerFunctions, RootLayout } from "@payloadcms/next/layouts"; +import { RootLayout } from "@payloadcms/next/layouts"; import React from "react"; import { importMap } from "./admin/importMap.js"; +import { serverFunction } from "./serverFunction"; import "./custom.scss"; type Args = { children: React.ReactNode; }; -const serverFunction: ServerFunctionClient = async function (args) { - "use server"; - return handleServerFunctions({ - ...args, - config, - importMap, - }); -}; - const Layout = ({ children }: Args) => ( { + return handleServerFunctions({ + ...args, + config, + importMap, + }); +};