date-fns auto-import module for Nuxt.
- Install
nuxt-date-fns
as development dependency:
npm i nuxt3-date-fns -D
yarn add nuxt3-date-fns -D
pnpm i nuxt3-date-fns -D
- Add it to the
modules
section of yournuxt.config
:
export default defineNuxtConfig({
modules: ["nuxt3-date-fns"],
});
Use any Date-Fns methods in your Nuxt application, they will be auto-imported!
<script setup>
const date = useFormat(new Date(2024, 1, 11), "MM/dd/yyyy");
</script>
<template>
<div>{{ date }}</div>
</template>
Name | Default | Description |
---|---|---|
prefix |
'use' |
String to prepend before each date-fns function (false to disable) |
export default defineNuxtConfig({
modules: ["nuxt3-date-fns"],
"date-fns": {
prefix: "_",
},
});
MIT License © 2024 - Siddharth Sarathe