A lightweight Nuxt 3 & 4 module that auto-imports functions from es-toolkit as Nuxt composables with full TypeScript support.
es-toolkit functionsisX) via prefixSkip.d.ts for IDE autocompleteUsing nuxt cli
npx nuxt module add @bubblesortt/nuxt-es-toolkit
or manual
@bubblesortt/nuxt-es-toolkit as development dependency:Using npm:
npm i -D @bubblesortt/nuxt-es-toolkit
Using pnpm:
pnpm add -D @bubblesortt/nuxt-es-toolkit
Using bun:
bun add -d @bubblesortt/nuxt-es-toolkit
modules section of your nuxt.config:export default defineNuxtConfig({
modules: ["@bubblesortt/nuxt-es-toolkit"],
});
export default defineNuxtConfig({
modules: ["@bubblesortt/nuxt-es-toolkit"],
esToolkit: {
// your options here
}
});
or
export default defineNuxtConfig({
modules: [
["@bubblesortt/nuxt-es-toolkit",
{
// your options here
},
],
],
});
When you use Es-toolkit utilities in your Nuxt application, they will be auto-imported
<script setup lang="ts">
const text = useUpperFirst("hello");
</script>
<template>
<div>{{ text }}</div>
</template>
| Name | Default | Description |
|---|---|---|
prefix | 'use' | String to prepend before each es-toolkit function (empty string to disable) |
exclude | [] | Array of es-toolkit functions to exclude from auto imports |
alias | [] | Array of array pairs to rename specific es-toolkit functions (prefix is still added) |
prefixSkip | ['is'] | Functions that starts with this keywords will be skipped by prefix (false to disable) |
export default defineNuxtConfig({
modules: ["@bubblesortt/nuxt-es-toolkit"],
esToolkit: {
prefix: "use",
prefixSkip: ["is"],
exclude: ["map", "find"],
alias: [
["sum", "total"], // => useTotal
["max", "maximum"], // => useMaximum
["isDate", "isExactlyDate"], // => isExactlyDate
],
},
});
.d.ts lets your IDE know about added composables instantly (after first nuxt dev run).es-toolkit provides proper ESM exports without side effects.# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release