Medusa module for Nuxt.
- Nuxt 3 ready
- Wrapper around
@medusajs/medusa-js
- Handy composables like
useMedusaClient
- Usage in API server routes with
serverMedusaClient
- TypeScript support
- Add
nuxt-medusa
dependency to your project
npm install --save-dev nuxt-medusa # pnpm or yarn
- Add
nuxt-medusa
to themodules
section ofnuxt.config.ts
:
export default defineNuxtConfig({
modules: ['nuxt-medusa'],
})
- Create .env file with following
MEDUSA_URL
variable:
MEDUSA_URL=<YOUR_MEDUSA_URL> # By default https://localhost:9000
And that's it! You can now fetch data from Medusa in Nuxt ✨
<script setup lang="ts">
const client = useMedusaClient();
const products = await client.products.list();
</script>
If you are encountering problems with CORS
from Medusa, make sure that process.env.STORE_CORS
in medusa-config.js
file is pointing to your local Nuxt project. By default, Medusa has CORS set for https://localhost:8000
while Nuxt is running by default on https://localhost:3000
# Install dependencies
yarn
# Generate type stubs
yarn dev:prepare
# Develop with the playground
yarn dev
# Build the playground
yarn dev:build
# Run ESLint
yarn lint
# Run Vitest
yarn test
yarn test:watch
# Release new version
yarn release