docs: create docs workspace (#5174)

* docs: migrate ui docs to docs universe

* created yarn workspace

* added eslint and tsconfig configurations

* fix eslint configurations

* fixed eslint configurations

* shared tailwind configurations

* added shared ui package

* added more shared components

* migrating more components

* made details components shared

* move InlineCode component

* moved InputText

* moved Loading component

* Moved Modal component

* moved Select components

* Moved Tooltip component

* moved Search components

* moved ColorMode provider

* Moved Notification components and providers

* used icons package

* use UI colors in api-reference

* moved Navbar component

* used Navbar and Search in UI docs

* added Feedback to UI docs

* general enhancements

* fix color mode

* added copy colors file from ui-preset

* added features and enhancements to UI docs

* move Sidebar component and provider

* general fixes and preparations for deployment

* update docusaurus version

* adjusted versions

* fix output directory

* remove rootDirectory property

* fix yarn.lock

* moved code component

* added vale for all docs MD and MDX

* fix tests

* fix vale error

* fix deployment errors

* change ignore commands

* add output directory

* fix docs test

* general fixes

* content fixes

* fix announcement script

* added changeset

* fix vale checks

* added nofilter option

* fix vale error
This commit is contained in:
Shahed Nasser
2023-09-21 20:57:15 +03:00
committed by GitHub
parent 19c5d5ba36
commit fa7c94b4cc
3209 changed files with 32188 additions and 31018 deletions

View File

@@ -0,0 +1,335 @@
---
description: 'Learn how to customize the Contentful integration with Medusa and how to customize the Gatsby storefront that is connected to Contentful.'
addHowToData: true
---
# Customize your Medusa and Contentful Integration
In this document, youll learn how to customize the Contentful integration with Medusa and how to customize the Gatsby storefront that is connected to Contentful.
:::warning
This guide covers how to customize the Gatsby storefront which is now deprecated. It's recommended to integrate Contentful into either the Next.js Starter Template or your custom storefront.
:::
## Overview
Part of what makes the integration between Medusa and Contentful powerful is that its completely customizable.
On the backend, you can create Contentful migrations that allow you to add or edit Content Types in Contentful. Although this can be done through Contentfuls interface, this solution allows you to create a reusable codebase for your store that is independent of a specific Contentful Space.
On your storefront, you can add any necessary components that can render the Content Types you create.
As an example to explain this process, in this documentation, youll create a migration that creates a Rich Text content model in Contentful and edits the Page and Product content models to allow using Rich Text content as a tile in pages and products. Then, youll modify the Gatsby storefront to render the Rich Text content model.
---
## Prerequisites
Its assumed you already have set up a Medusa backend integrated with Contentful and have a Gatsby storefront integrated with Contentful. If not, [please follow this documentation first](index.md).
---
## Create a Contentful Migration
The Contentful migrations are located in the `contentful-migrations` directory in the Medusa Contentful backend starter. So, if you want to create your own Contentful migrations, you can create them under that directory.
Heres an example of a migration created in a new file `contentful-migrations/rich-text.js`:
```jsx title=contentful-migrations/rich-text.js
#! /usr/bin/env node
require("dotenv").config()
const { runMigration } = require("contentful-migration")
const options = {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
environment: process.env.CONTENTFUL_ENVIRONMENT,
yes: true,
}
const migration = async () => {
await runMigration({
...options,
migrationFunction: function (migration, context) {
// create Rich Text content model
const richText = migration
.createContentType("richText")
.name("Rich Text")
.displayField("title")
richText
.createField("title")
.name("Title (Internal)")
.type("Symbol")
richText
.createField("body")
.name("Body")
.type("RichText")
// edit Page content model
const page = migration.editContentType("page")
page.editField("contentModules").items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: [
"hero", "tileSection", "richText",
],
},
],
})
// edit Product content model
const product = migration.editContentType("product")
product
.createField("contentModules")
.name("Content Modules")
.type("Array")
.items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: ["richText"],
},
],
})
},
})
}
migration()
```
This example creates a new content model Rich Text that has two fields: title and body. It also edits the Page content model to allow using Rich Text content models on the page.
In addition, it edits the Product content model by adding a new field `contentModules`. This field accepts an array of sections that can be of type Rich Text. This allows you to display rich details on a product page.
You can also add other types of content models the `contentModules` should accept. For example, to accept `tileSection` add it to the `linkContentType` option:
```jsx
product
.createField("contentModules")
.name("Content Modules")
.type("Array")
.items({
type: "Link",
linkType: "Entry",
validations: [
{
linkContentType: ["richText", "tileSection"],
},
],
})
```
### Run a Contentful Migration
To run a Contentful Migration that you create you can use the following command:
```bash
node <file_path>
```
Where `<file_path>` is the path of the file you created.
To run the Contentful migration in the previous example, you can use the following command:
```bash
node contentful-migrations/rich-text.js
```
This runs the Contentful migration in that file and makes the necessary changes in your Contentful Space.
### Test if Contentful Migration Worked
To check if the above migration worked, in your Contentful Space dashboard go to Content Models from the navigation bar. You should see the new content model Rich Text.
The above migration also allows you to add Rich Text content to pages. To test this out:
1. Go to Content from the navigation bar.
2. Choose Page in the select field next to the search bar. This shows the available pages in your Contentful Space.
3. Choose one of the pages. For example, the About page.
4. Scroll down to the Add content button. If you click on it, you should be able to choose Rich Text under New Content.
5. Click on Rich Text and a new form will open to create new Rich Text content. It has the same fields that you defined in the migration file.
6. After adding the content you want, click on the Publish button on the right then go back to the About page editor.
7. Similarly, in the About page editor, click on the Publish Changes button on the right to view these changes later in the storefront.
8. Similarly, you can add Rich Text content to any product page.
---
## Render New Content Models in the Storefront
After creating a new content model in your Contentful Space, you must add the necessary component to render it in your Gatsby storefront.
### Create Component
To render the Rich Text content you created in the previous example, create the file `src/components/rich-text/rich-text.js` with the following content:
```jsx title=src/components/rich-text/rich-text.js
import React from "react"
import {
renderRichText,
} from "gatsby-source-contentful/rich-text"
const RichText = ({ data }) => {
return (
<div style={{
maxWidth: "870px",
margin: "0 auto",
paddingTop: "20px",
paddingBottom: "20px",
}}>
{data.body ? renderRichText(data.body) : ""}
</div>
)
}
export default RichText
```
This creates the component `RichText` responsible for rendering the Rich Text content model. Notice that the fields of the content model are available under the `data` prop variable.
### Render Component in a Page
Since the Rich Text model can be added to any page, you must edit `src/pages/{ContentfulPage.slug}.js` to show it.
In `src/pages/{ContentfulPage.slug}.js`, import the `RichText` component at the top of the file:
```jsx title=src/pages/{ContentfulPage.slug}.js
import RichText from "../components/rich-text/rich-text"
```
Then, in the returned JSX add a new case to the switch statement:
```jsx title=src/pages/{ContentfulPage.slug}.js
switch (cm.internal.type) {
// ...
case "ContentfulRichText":
return <RichText key={cm.id} data={cm} />
default:
return null
}
```
If the content model of a tile is Rich Text, youll display it with the `RichText` component.
Finally, to retrieve all necessary data of the Rich Text content, in the `query` GraphQL variable add the following after the `... on ContentfulTileSection` fragment:
```jsx title=src/pages/{ContentfulPage.slug}.js
export const query = graphql`
# find the following line
... on ContentfulTileSection {
}
# add the following
... on ContentfulRichText {
id
body {
raw
}
internal {
type
}
}
}
}
}
`
```
### Test Rich Text in Page Content
To test this out, run your Medusa backend by running this command in its directory:
```bash npm2yarn
npx medusa develop
```
Then run the Gatsby storefront by running this command in its directory:
```bash npm2yarn
npm run start
```
This runs the Gatsby storefront on `localhost:8000`. Go to the storefront in your browser and open the About page. You should see the Rich Text content you added.
### Render Component in a Product Page
In the example migration, you also edited the product page to include a new Content Modules field that allows inserting Rich Text content.
To render them on the Product Page, add the following in the GraphQL query defined in the `query` variable inside `product`:
```jsx title=src/pages/{ContentfulPage.slug}.js
export const query = graphql`
query ($id: String!) {
product: contentfulProduct(id: { eq: $id }) {
# Other fields
contentModules {
... on ContentfulRichText {
id
body {
raw
}
internal {
type
}
}
}
}
}
`
```
:::note
If you added other accepted Content Models to the `contentModules` field of the Product content type, make sure to add them here.
:::
Then, in `src/views/product.js` import the `RichText` component:
```jsx title=src/views/product.js
import RichText from "../components/rich-text/rich-text"
```
And in the returned JSX add the following before the last `</div>`:
```jsx title=src/views/product.js
<div className={styles.contentModules}>
{product.contentModules?.map((cm) => {
switch (cm.internal.type) {
case "ContentfulRichText":
return <RichText key={cm.id} data={cm} />
default:
return null
}
})}
</div>
```
:::note
If you added other accepted Content Models to the `contentModules` field of the Product content type, make sure to add cases for them here to display them.
:::
This loops over `contentModules` and if the type of the content is Rich Text, it is rendered with the `RichText` component.
### Test Rich Text on a Product Page
Restart the Gatsby storefront then open a product that you added Rich Text content to. You should see the Rich Text component at the end of the page.
---
## See Also
- How to deploy your Medusa backend to [Heroku](../../../deployments/server/deploying-on-heroku.mdx), or [DigitalOcean](../../../deployments/server/deploying-on-digital-ocean.md), or [other providers](../../../deployments/server/index.mdx)

View File

@@ -0,0 +1,297 @@
---
description: 'Learn how to integrate Contentful with the Medusa backend and a Gatsby storefront. Contentful is a headless CMS backend that provides rich CMS functionalities.'
addHowToData: true
---
# Contentful
In this document, youll learn how to integrate a Medusa backend with Contentful to add rich Content Management System (CMS) functionalities
## Overview
[Contentful](https://www.contentful.com/) is a headless CMS service that allows developers to integrate rich CMS functionalities into any platform.
By integrating Contentful to Medusa, you can benefit from powerful features in your ecommerce store including detailed product CMS details, easy-to-use interface to use for static content and pages, localization, and much more.
---
## Prerequisites
### Needed Accounts
- [Contentful](https://www.contentful.com/sign-up/) account with a space created. A space is created by default when you create a new account.
### Required Tools
- PostgreSQL with an empty database created. You can follow [this documentation to learn how to install it for your operating system](../../../development/backend/prepare-environment.mdx#postgres).
- Redis. You can follow [their documentation to learn how to install it](https://redis.io/docs/getting-started/installation/).
- Gits CLI tool. You can follow [this documentation to learn how to install it for your operating system](../../../development/backend/prepare-environment.mdx#git).
- Gatsbys CLI tool. You can follow [this documentation to install it](https://www.gatsbyjs.com/docs/reference/gatsby-cli/#how-to-use-gatsby-cli).
- Medusas CLI tool. You can follow [this documentation to install it](../../../cli/reference.mdx#how-to-install-cli-tool).
---
## Install Medusa Backend Using Contentful Starter
Instead of using the default Medusa backend starter, you must use the [Contentful starter](https://github.com/medusajs/medusa-starter-contentful) to install a backend that is ready to be used with Contentful. This backend contains all the necessary files to make the integration work.
In your terminal, run the following command to install the backend:
```bash
npx @medusajs/medusa-cli@latest new medusa-contentful https://github.com/medusajs/medusa-starter-contentful
```
This installs a new Medusa backend in the directory `medusa-contentful`.
### Add Contentful Environment Variables
Change to the `medusa-contentful` directory. In `.env` youll find three variables:
```bash title=.env
CONTENTFUL_SPACE_ID=
CONTENTFUL_ACCESS_TOKEN=
CONTENTFUL_ENV=
```
#### Value of CONTENTFUL_ENV
Set the value for `CONTENTFUL_ENV` to `master`.
#### Value of CONTENTFUL_SPACE_ID
To retrieve the value of `CONTENTFUL_SPACE_ID`:
1. Go to your [Contentful Space dashboard](https://app.contentful.com/). Then, choose Settings in the navigation bar and select API keys from the dropdown.
2. On the APIs page, click Add API Key.
3. In the form, enter a name for the API key and click Save.
4. Copy the value of Space ID and set it as the value of `CONTENTFUL_SPACE_ID`.
#### Value of CONTENTFUL_ACCESS_TOKEN
To retrieve the value of `CONTENTFUL_ACCESS_TOKEN`:
1. Go back to the API Keys page and click on the Content management tokens tab.
2. Click on Generate personal token.
3. In the pop-up that opens, enter a name for the token.
4. Click the Generate button. A personal access token will be generated. Use it to set the value of `CONTENTFUL_ACCESS_TOKEN`.
:::warning
Once you close the pop-up, you wont be able to get the value of the personal access token again. Make sure to copy it first.
:::
### Configure Redis
In `.env` set the value of your Redis URL:
```bash
REDIS_URL=<YOUR_REDIS_URL>
```
Where `<YOUR_REDIS_URL>` is the URL of your Redis service.
:::tip
The default Redis URL is `redis://localhost:6379`.
:::
### Configure PostgreSQL
In `.env` set the value of your PostgreSQL URL:
```bash
DATABASE_URL=<YOUR_DB_URL>
```
Where `<YOUR_DB_URL>` is the URL of your PostgreSQL database.
:::tip
You can find the format of the PostgreSQL database URL in [PostgreSQLs documentation](https://www.postgresql.org/docs/current/libpq-connect.html).
:::
Then, in `medusa-config.js` in the exported object, add the PostgreSQL database configurations:
```jsx title=medusa-config.js
module.exports = {
projectConfig: {
// ...
database_url: DATABASE_URL,
database_type: "postgres",
},
}
```
### Migrate Content Types to Contentful
The Contentful starter provides the necessary scripts to create content types in your Contentful space.
Run the following commands to migrate the content types into Contentful:
```bash
npm run migrate:contentful
```
Once this command finishes executing, in your Contentful Space dashboard click on Content Model in the navigation bar. You should see a list of new content models added.
### Seed Content to Contentful
The next step is to seed the Contentful Space with some content data.
Run the following command to seed some data into it:
```bash
npm run seed:contentful
```
After this command finishes running, in your Contentful Space dashboard click on Content in the navigation bar. You should see a list of new content added.
### (Optional) Seed Medusa Database
This step seeds your Medusa database with demo data to easily add products as well as other data to your Medusa backend.
Run the following command to seed the Medusa database:
```bash
npm run seed
```
### Start the Backend
To start the backend run the following command:
```bash
npx medusa develop
```
If you seeded the database with demo data, you should see that events related to the products are triggered.
The Contentful integration ensures a sync between the Medusa backend and Contentful. So, when new products are added to Medusa, these products will be added to your Contentful Space as well.
---
## (Optional) Add Products with the Medusa Admin
Using the Medusa admin, you can add products to your Medusa backend. This will trigger product events that subsequently add these products to Contentful.
---
## (Optional) Two-way Sync with Contentful
This section explains how you can establish a two-way sync between Medusa and Contentful. This would ensure that not only is the data updated from the Medusa backend to Contentful, but also ensure the updates are relayed from Contentful to the Medusa backend.
However, to perform this sync, it's required that you deploy your backend so that it can be publicly accessible. You can learn how to do that through the [backend deployment](../../../deployments/server/index.mdx) guides.
Configuring two-way sync requires configuring Webhooks in Contentful. To do that:
1. On your Contentful Space Dashboard, click on Settings from the navigation bar, then choose Webhooks.
2. Click on the Add Webhook button.
3. In the form, enter a name for the webhook.
4. In the URL field, choose the method `POST` and in the input next to it enter the URL `<BACKEND_URL>/hooks/contentful` where `<BACKEND_URL>` is the URL of your production Medusa backend.
5. Scroll down to find the Content Type select field. Choose `application/json` as its value.
6. You can leave the rest of the fields the same and click on the Save button.
Now, every time you change a products data on your Contentful Space it will be updated on your Medusa backend as well.
---
## Manage Contentful Data
### Publish Products
Products added through the integration with the Medusa backend are by default saved as drafts. To show them on the storefront, you must set them as published.
To do that, open your Contentful Space Dashboard and click on Content in the Navigation bar. Then, change Any to Product in the select field next to the search bar. This shows only the content of the type Product, rather than all content.
Click on the checkbox at the top of the table to select all products then click Publish to publish these products.
### Added Featured Products
On the homepage of the storefront, theres a featured products tile that shows a set of products. Before running the storefront, you must add at least one product to the list.
To do that:
1. Open your Contentful Space Dashboard and click on Content in the Navigation bar.
2. Set the select field next to the search bar Any and search for Featured Products. You should find one content of the type Tile Section.
3. Click on the result. You should find on the page an empty Tiles section where you can add tiles and products.
4. Click on the "Add content" button, then on "Add existing content" from the dropdown.
5. Pick some of the products you want to show on the homepage.
6. Once youre done adding products, click on Publish changes in the right sidebar.
---
## Setup Gatsby Storefront
:::warning
This Gatsby storefront is deprecated. It's recommended to integrate Contentful into either the Next.js Starter Template or your custom storefront.
:::
In this section, youll set up the Gatsby storefront of your Medusa backend.
In your terminal in a different directory of the Medusa backend, run the following command:
```bash
gatsby new medusa-contentful-storefront https://github.com/medusajs/medusa-contentful-storefront
```
This will install the storefront in the directory `medusa-contentful-storefront`.
### Set Contentful Environment Variables
Change to the newly created directory and rename `.env.template`:
```bash
mv .env.template .env
```
Then, open `.env`. You should find the following environment variables:
```bash title=.env
CONTENTFUL_SPACE_ID=
CONTENTFUL_ACCESS_TOKEN=
```
The value of `CONTENTFUL_SPACE_ID` is the same value you [retrieved while setting up the Medusa backend](#value-of-contentful_space_id).
To retrieve the value of `CONTENTFUL_ACCESS_TOKEN`:
1. On your Contentful Space dashboard click on Settings in the navigation bar then choose API keys.
2. Choose the API key you created in the previous section.
3. You should find the field "Content Delivery API - access token”. Copy its value and set it as the value of `CONTENTFUL_ACCESS_TOKEN`.
### Start Storefront
Make sure the Medusa backend is still running. Then, start the storefront:
```bash npm2yarn
npm run start
```
This starts the storefront at `localhost:8000`. Open it in your browser and you should see on the homepage the Featured Product section with the products you chose on Contentful.
---
## Make Changes to Content
You can update the CMS content of your storefront in your Contentful Space. This includes the CMS pages or product details.
:::note
If you make changes to the data while your Gatsby storefront is running, the changes are not reflected instantly. Thats because the data is fetched from Contentful during build time. Instead, you must restart your Gatsby storefront to see the changes you make.
:::
---
## Whats Next
Learn [How to customize your Contentful backend and storefront](./customize-contentful.md).
## See Also
- How to deploy your Medusa backend to [Heroku](../../../deployments/server/deploying-on-heroku.mdx), or [DigitalOcean](../../../deployments/server/deploying-on-digital-ocean.md), or [other providers](../../../deployments/server/index.mdx)

View File

@@ -0,0 +1,7 @@
import DocCardList from '@theme/DocCardList';
# CMS Plugins
If you can't find your CMS provider, try checking the [Community Plugins Library](https://medusajs.com/plugins/?filters=CMS&categories=CMS).
<DocCardList />

View File

@@ -0,0 +1,202 @@
---
description: 'Learn how to integrate Strapi with the Medusa backend. Learn how to install the plugin and test two-way sync between the ecommerce and CMS services.'
addHowToData: true
---
# Strapi
In this document, youll learn how to integrate Strapi with Medusa to add rich Content Management System (CMS) functionalities.
:::info
This plugin is a [community plugin](https://github.com/Deathwish98/medusa-plugin-strapi) and is not managed by the official Medusa team. At the moment, it supports v4 of Strapi.
:::
## Overview
[Strapi](https://strapi.io/) is an open source headless CMS service that allows developers to have complete control over their content models. It can be integrated into many other frameworks, including Medusa.
By integrating Strapi to Medusa, you can benefit from powerful features in your ecommerce store including detailed product CMS details, [two-way sync](#test-two-way-sync), an easy-to-use interface to use for static content and pages, and much more.
---
## Prerequisites
### Medusa CLI
[Medusas CLI tool](../../cli/reference.mdx#how-to-install-cli-tool) is required to set up a new Medusa backend.
### Redis
Redis is required for the Strapi plugin to work as expected on your Medusa backend. If you dont have it installed, you can learn [how to install it in this documentation](../../development/backend/prepare-environment.mdx#redis).
---
## Create Strapi Project
The first step is to create a Strapi project using the Medusa template:
```bash
npx create-strapi-app strapi-medusa --template shahednasser/strapi-medusa-template
```
This creates the Strapi project in the directory `strapi-medusa`.
Once the installation is finished, the Strapi development backend will run on `localhost:1337`. A new page will also open in your default browser to create a new admin user and log in.
![Create User Form in Strapi](https://res.cloudinary.com/dza7lstvk/image/upload/v1668001083/Medusa%20Docs/Strapi/9pFE1Ij_h2dicv.png)
Once you log in, you can access the Strapi dashboard.
### Create a Strapi User
The Strapi plugin in Medusa requires the credentials of a Strapi user. To create a new user, go to Content Manager, then choose User under Collection Types.
![Showing the users under Content Manager](https://res.cloudinary.com/dza7lstvk/image/upload/v1668001096/Medusa%20Docs/Strapi/YyGJPUf_mr5sx7.png)
Click on the Create new entry button at the top right. This opens a new form to enter the users details.
![Create User Form on Strapi](https://res.cloudinary.com/dza7lstvk/image/upload/v1668001105/Medusa%20Docs/Strapi/mdMhSlV_vy7ygv.png)
Enter the users username, email, and password. Once youre done, click on the Save button at the top right.
---
## Modify Permissions
By default, created users have the “Authenticated” role. Before you start using the Strapi plugin on your Medusa backend, you must modify this roles permissions to allow making changes to Medusas models in Strapi.
On your Strapi dashboard, go to Settings → Roles → Authenticated. Then, under the Permissions section, expand the accordion of each content model type and check the Select All checkbox.
![An example of modifying permissions on the Product content type](https://res.cloudinary.com/dza7lstvk/image/upload/v1668001116/Medusa%20Docs/Strapi/QgckXqS_wlyxe8.png)
Once youre done, click the Save button at the top right.
---
## Create Medusa Backend
:::note
You can use the Strapi plugin on an existing Medusa backend, however, existing data (such as existing products) will not be imported. Only newer data will be imported.
:::
To create your Medusa backend, run the following command:
```bash
npx @medusajs/medusa-cli@latest new medusa-backend
```
### Configure your Backend
Once the command is done executing, change to the newly created `medusa-backend` directory:
```bash
cd medusa-backend
```
You must then configure your backend to:
- Connect to a PostgreSQL database, as explained [here](../../development/backend/configurations.md#database-configuration)
- Install and configure an event-bus module, as explained [here](../../development/backend/configurations.md#recommended-event-bus-modules)
### Run Migrations
After configuring the connection to the database, you must run migrations to add the necessary database schema definitions in your database. To do that, run the following command in the `medusa-backend` directory:
```bash
npx @medusajs/medusa-cli@latest migrations run
```
You can optionally seed your database with demo data by running the `seed` command:
```bash
npx @medusajs/medusa-cli@latest seed --seed-file=data/seed.json
```
---
## Install the Strapi Plugin
In the directory of your Medusa backend, run the following command to install the Strapi plugin:
```bash npm2yarn
npm install medusa-plugin-strapi
```
Then, add the following environment variables:
```bash
STRAPI_USER=<STRAPI_IDENTIFIER>
STRAPI_PASSWORD=<STRAPI_PASSWORD>
STRAPI_PROTOCOL=http # Optional
STRAPI_URL=<STRAPI_URL> # Optional
STRAPI_PORT=<STRAPI_PORT> # Optional
```
Where:
- `<STRAPI_IDENTIFIER>` is either the email address or username of the user you created in the previous step.
- `<STRAPI_PASSWORD>` is the password of the user you created in the previous step.
- `<STRAPI_PROTOCOL>` is the protocol of your Strapi backend. If youre using a local Strapi backend, set this to `http`. The default value is `https`.
- `<STRAPI_URL>` is the URL of your Strapi backend. By default, the URL is `localhost`.
- `<STRAPI_PORT>` is the port the Strapi backend runs on. By default, the port is `1337`.
Finally, open `medusa-config.js` and add the following new item to the `plugins` array:
```jsx title=medusa-config.js
const plugins = [
// ...
{
resolve: `medusa-plugin-strapi`,
options: {
strapi_medusa_user: process.env.STRAPI_USER,
strapi_medusa_password: process.env.STRAPI_PASSWORD,
strapi_url: process.env.STRAPI_URL, // optional
strapi_port: process.env.STRAPI_PORT, // optional
strapi_protocol: process.env.STRAPI_PROTOCOL, // optional
},
},
]
```
---
## Run Medusa Backend
Make sure the Strapi backend is still running. If not, you can run the following command to run the Strapi backend in the directory of the Strapi project:
```bash npm2yarn
npm run develop
```
Then, in the directory of your Medusa backend, run the following command to start the Medusa backend:
```bash npm2yarn
npx medusa develop
```
Once you start your Medusa backend, if you ran the `--seed` command when you created your Medusa backend, youll see that `product.created` events have been triggered along with similar events. This will update Strapi with the products you seeded.
---
## Test Two-Way Sync
This plugin ensures a two-way sync between the Medusa backend and the Strapi backend. So, if you update data on Strapi, it will be reflected on your Medusa backend, and vice-versa.
### Update Products on Strapi
Try updating any products on Strapi by going to Content Manager → Products and choosing a product from the list. Then, make changes to the product and click Save. If you view the products on your backend now, either using the [REST APIs](https://docs.medusajs.com/api/admin#products_getproducts) or using [the Medusa Admin](../../user-guide/products/index.mdx), youll see that the product has been updated.
### Update Products on Medusa
If you try to update products on Medusa either using the [REST APIs](https://docs.medusajs.com/api/admin#products_postproductsproduct) or using [the Medusa Admin](../../user-guide/products/manage.mdx), youll see that the product is also updated on Strapi.
---
## See Also
- [Deploy the Medusa backend](../../deployments/server/index.mdx)
- [Create your own plugin](../../development/plugins/create.mdx)