Skip to content

Baroshem/nuxt-medusa

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
February 24, 2023 08:28
October 4, 2023 13:29
October 25, 2023 11:09
src
October 25, 2023 11:09
February 23, 2023 08:18
February 23, 2023 08:18
February 23, 2023 08:18
February 23, 2023 08:18
February 23, 2023 10:37
February 23, 2023 08:18
February 23, 2023 10:37
February 24, 2023 08:32
February 27, 2023 18:12
October 4, 2023 12:55
October 25, 2023 11:09
February 23, 2023 08:18

Nuxt Medusa

nuxt-medusa

npm version npm downloads License

Medusa module for Nuxt.

Features

  • Nuxt 3 ready
  • Wrapper around @medusajs/medusa-js
  • Handy composables like useMedusaClient
  • Usage in API server routes with serverMedusaClient
  • TypeScript support

Quick Setup

  1. Add nuxt-medusa dependency to your project
npm install --save-dev nuxt-medusa # pnpm or yarn
  1. Add nuxt-medusa to the modules section of nuxt.config.ts:
export default defineNuxtConfig({
  modules: ['nuxt-medusa'],
})
  1. Create .env file with following MEDUSA_URL variable:
MEDUSA_URL=<YOUR_MEDUSA_URL> # By default http://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 http://localhost:8000 while Nuxt is running by default on http://localhost:3000

Development

# 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