Setup
Connect to Medusa Platform easily from Nuxt with following commands ✨
Installation
- Add
nuxt-medusa
dependency to your project:
npx nuxi@latest module add medusa
- Create an
.env
file with the followingMEDUSA_URL
variable:
MEDUSA_URL=<YOUR_MEDUSA_URL> # By default http://localhost:9000
That's it! You can now fetch data from Medusa in your Nuxt app ✨
<script setup lang="ts"> const client = useMedusaClient(); const { products } = await client.store.product.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
Options
You can customize the module's behavior by using the medusa
property in nuxt.config
:
nuxt.config
export default { medusa: { // Options }}
See the module options.
Table of Contents