@favorodera/nuxt-app-utils
v1.1.0
Published
A collection of utilities for Nuxt applications
Readme
@favorodera/nuxt-app-utils
A collection of typed utilities and composables for Nuxt applications — covering the app, server, and shared layers.
Features
- App composables and utilities — reactive composables and utilities for use in Vue components and pages
- Server composables and utilities — composables and utilities scoped to Nitro server routes
- Shared composables and utilities — composables and utilities available in both the app and server layers
- Fully typed with TypeScript throughout
- Zero runtime dependencies beyond Nuxt itself
Setup
Install the module to your Nuxt application:
npx nuxi module add @favorodera/nuxt-app-utilsOr manually:
pnpm add @favorodera/nuxt-app-utils// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@favorodera/nuxt-app-utils'],
})That's it — all utilities and composables are auto-imported in their respective layers. ✨
API Reference
App — Composables and Utilities
Auto-imported in components, pages, and plugins.
| Composable/Utility | Description |
|---|---|
| usePromise | Wraps any async callback with reactive status, data, and error state |
| getError | Extracts a normalized message and status code from an unknown error |
| getInitials | Extracts up to two uppercase initials from any string |
Server — Composables and Utilities
Auto-imported in server/ routes and middleware.
| Composable/Utility | Description | |---|---| | — | — |
Shared — Composables and Utilities
Auto-imported in both the app and server layers.
| Composable/Utility | Description |
|---|---|
| normalizeZodError | Normalizes a ZodError into a Nuxt H3 error with a human-readable message and a structured issues list |
Contributing
# Install dependencies
pnpm install
# Generate type stubs
pnpm run prepare
# Develop with stub mode
pnpm run dev
# Run ESLint
pnpm run lint
# Run tests
pnpm run test
pnpm run test:watch
# Type check
pnpm run typecheck
# Release stable version
pnpm run release
# Release prerelease version
pnpm run prerelease