@drmhse/authos-cli
CLI tool for scaffolding AuthOS authentication components in your project.
Installation
npm install @drmhse/authos-cli -g
Or use without installing globally:
npx @drmhse/authos-cli init
Commands
authos init
Initialize AuthOS in your project. This command detects your framework (React, Next.js, Vue, Nuxt) and sets up the appropriate configuration.
authos init
The init command will:
- Detect your framework from package.json dependencies
- Install the appropriate AuthOS adapter package (
@drmhse/authos-reactor@drmhse/authos-vue) - Set up the AuthOS provider/plugin in your app
authos add
Generate and add AuthOS components to your project.
authos add <template>
Available templates:
login-form- Styled login form with email/password and MFA supportorg-switcher- Dropdown for switching between organizationsuser-profile- User avatar button with dropdown menu
Examples
React / Next.js Project
# Initialize AuthOS in a Next.js project
authos init
# Add a login form component
authos add login-form
# Add organization switcher
authos add org-switcher
# Add user profile component
authos add user-profile
Vue / Nuxt Project
# Initialize AuthOS in a Nuxt project
authos init
# Add components
authos add login-form
authos add org-switcher
authos add user-profile
Templates
login-form
A styled login form component with:
- Email and password fields
- MFA (TOTP) support
- Loading states
- Error handling
org-switcher
A dropdown component for switching between organizations when a user belongs to multiple organizations.
user-profile
A user avatar button with:
- Avatar display (with fallback to initials)
- Dropdown menu showing user info
- Sign out functionality
Programmatic Usage
You can also use the CLI programmatically:
import { initCommand, addCommand, getAvailableTemplates } from '@drmhse/authos-cli';
// Get available templates
const templates = getAvailableTemplates();
console.log(templates); // ['login-form', 'org-switcher', 'user-profile']
// Initialize AuthOS
await initCommand({
projectDir: process.cwd(),
framework: 'next'
});
// Add a component
await addCommand({
projectDir: process.cwd(),
template: 'login-form'
});
Troubleshooting
Framework Detection Failed
If authos init fails to detect your framework:
- Ensure you are in the root directory of your project (where
package.jsonis). - Manually specify the framework when initializing:
# For Next.js/React
authos init --framework next
# For Nuxt/Vue
authos init --framework nuxt
Component Installation Errors
If authos add fails to write files:
- Check that you have a
components/directory in your project. - Ensure you have write permissions in your project directory.
- Try running with verbose logging (if available) or check console output for specific error messages.
License
MIT © DRM HSE