Skip to content

UseGetDirname

katanakit-js / useGetDirname

function useGetDirname(importMetaUrl): Promise<string>;

Defined in: infrastructure/filesystem/path.service.ts:63

Resolves the directory of a module from its import.meta.url.

Unlike import.meta.dirname, this works for any module you pass in, so a consumer’s app resolves its own paths — never KatanaKit’s dist/.

Parameter Type Description
importMetaUrl string Your module’s import.meta.url.

Promise<string>

The absolute directory that contains the module.

import { useGetDirname } from "katanakit-js";
const dir = await useGetDirname(import.meta.url);
// "<project>/src/features/books"