@medusajs/user
Documentation | Website
Building blocks for digital commerce
User Module for Medusa: manages admin users and invites, including generating and validating invite tokens. It's installed and registered by default with @medusajs/medusa, which passes it the JWT settings from your project config, so Medusa applications use it through the Modules.USER service rather than installing this package directly.
At a glance
| Package | @medusajs/user |
| Type | Commerce Module |
| Module key | Modules.USER ("user") |
| Registered by default | Yes |
| Import from | @medusajs/medusa/user |
Installation
No installation needed. The module ships with @medusajs/medusa and is registered by defineConfig.
Usage
To customize the module's options, such as the invite token's validity, register it in medusa-config.ts:
import { defineConfig } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/user",
options: {
jwt_secret: process.env.JWT_SECRET,
valid_duration: 60 * 60 * 24,
},
},
],
})
Configuration
| Option | Type | Description | Default |
|---|---|---|---|
jwt_secret |
string |
Secret used to sign invite tokens (or the private key when using asymmetric signing). Required: the module throws on startup if it's missing. | projectConfig.http.jwtSecret, then the JWT_SECRET environment variable (set by defineConfig) |
jwt_public_key |
string |
Public key used to verify invite tokens when using asymmetric signing. | projectConfig.http.jwtPublicKey (set by defineConfig) |
valid_duration |
number |
How long an invite token is valid, in seconds. | jwt_options.expiresIn, then 86400 (24 hours) |
jwt_options |
object |
jsonwebtoken sign options, such as algorithm. |
projectConfig.http.jwtOptions (set by defineConfig) |
jwt_verify_options |
object |
jsonwebtoken verify options, such as algorithms. Falls back to jwt_options when not set. |
projectConfig.http.jwtVerifyOptions (set by defineConfig) |