What are Nuxt.js composables?

Answer

Composables in Nuxt.js are reusable functions that encapsulate stateful logic using Vue's Composition API. They are stored in the composables/ directory and are auto-imported throughout the application without explicit import statements. Nuxt also provides built-in composables like useAsyncData, useFetch, useState, useRoute, useRouter, useRuntimeConfig, and useCookie. Composables make it easy to share logic between components while keeping it reactive and SSR-compatible. The naming convention is use + PascalCase (e.g., useUser).