A wishlist plugin for Medusa v2 that allows customers to save products for later and share their wishlists with others.
- šļø Customer Wishlists - Each customer gets their own wishlist, automatically created when they add their first item
- ā Add/Update Items - Customers can add products to their wishlist and update quantities
- šļø Remove Items - Easy removal of items from the wishlist
- š Share Wishlists - Generate shareable links using JWT tokens
- š Public Access - Shared wishlists can be viewed without authentication
- š Secure - JWT-based token system for sharing
- Install the plugin:
npm install @rsc-labs/medusa-wishlist
# or
yarn add @rsc-labs/medusa-wishlist- Add the plugin to your
medusa-config.js:
const plugins = [
// ... other plugins
{
resolve: "@rsc-labs/medusa-wishlist",
options: {
jwtSecret: process.env.JWT_SECRET || "supersecret"
}
}
]Or simply:
const plugins = [
// ... other plugins
"@rsc-labs/medusa-wishlist"
]- Run database migrations:
npx medusa db:migrateYou can also copy the source code directly into your Medusa project:
- Copy the
/srcdirectory contents into your project - Add the module to your
medusa-config.js:
const modules = [
// ... other modules
{
resolve: "./src/modules/wishlist",
options: {
jwtSecret: process.env.JWT_SECRET || "supersecret"
}
}
]- Install required dependencies:
npm install jsonwebtoken
# or
yarn add jsonwebtoken- Run database migrations:
npx medusa db:migrateThe wishlist sharing feature uses JWT tokens. It's recommended to set a strong secret in your environment variables:
# .env
JWT_SECRET=your-super-secret-key-hereThen configure it in medusa-config.js:
{
resolve: "@rsc-labs/medusa-wishlist",
options: {
jwtSecret: process.env.JWT_SECRET
}
}GET /store/customers/me/wishlist
Authorization: Bearer {customer-token}
POST /store/customers/me/wishlist/items
Authorization: Bearer {customer-token}
Content-Type: application/json
{
"productId": "prod_01XXXXX",
"productVariantId": "variant_01XXXXX",
"quantity": 1
}
DELETE /store/customers/me/wishlist/items?productId={productId}&productVariantId={productVariantId}
Authorization: Bearer {customer-token}
POST /store/customers/me/wishlist/share-token
Authorization: Bearer {customer-token}
Response:
{
"shared_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
GET /store/wishlists?token={shared-token}
curl -X POST http://localhost:9000/store/auth/customer/emailpass \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password123"
}'curl -X POST http://localhost:9000/store/customers/me/wishlist/items \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"productId": "prod_01XXXXX",
"productVariantId": "variant_01XXXXX",
"quantity": 1
}'curl -X GET http://localhost:9000/store/customers/me/wishlist \
-H "Authorization: Bearer {token}"curl -X POST http://localhost:9000/store/customers/me/wishlist/share-token \
-H "Authorization: Bearer {token}"curl -X GET "http://localhost:9000/store/wishlists?token={shared-token}"The plugin creates the following tables:
id- Primary keycreated_at- Timestampupdated_at- Timestamp
id- Primary keywishlist_id- Foreign key to wishlistproduct_id- Product identifierproduct_variant_id- Product variant identifierquantity- Item quantitycreated_at- Timestampupdated_at- Timestamp
- Links customers to their wishlists (1:1 relationship)
- Automatic Creation: When a customer adds their first item, a wishlist is automatically created and linked to their account
- Item Management: Customers can add, update quantities, or remove items from their wishlist
- Sharing: Customers can generate a JWT token to share their wishlist with others
- Public Access: Anyone with the share token can view the wishlist without authentication
For detailed API specifications, see the OpenAPI documentation.
- Node.js 20+
- Medusa v2
- PostgreSQL
# Install dependencies
npm install
# Run migrations
npx medusa db:migrate
# Start development server
npm run devContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.
Created by RSC Labs
For issues and questions:
- GitHub Issues: medusa-wishlist/issues
- Documentation: docs.medusajs.com
Built for Medusa v2 š