@nimpl/getters
Version:
Implementation of server getters in React Server Components without switching to SSR in next.js
15 lines (14 loc) • 842 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAppPathname = void 0;
const work_unit_async_storage_external_1 = require("next/dist/server/app-render/work-unit-async-storage.external");
const server_getter_in_client_component_error_1 = require("./server-getter-in-client-component-error");
function getAppPathname() {
(0, server_getter_in_client_component_error_1.serverGetterInClientComponentError)("getAppPathname");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pageStore = work_unit_async_storage_external_1.workUnitAsyncStorage.getStore();
const pageTags = pageStore.implicitTags.filter((tag) => tag.startsWith("_N_T_/"));
const pathnameTag = pageTags[pageTags.length - 1];
return pathnameTag.substring(5);
}
exports.getAppPathname = getAppPathname;