npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

trompt

v1.0.1

Published

Modern CLI questionary library with TypeScript support

Readme

Trompt

NPM version License PR Welcome

🚀 Modern CLI questionnaire library - Interactive terminal prompts with style!

A modernized, ES module-compatible CLI prompt library similar to inquirer, with support for various input types and validation.

trompt

✨ Features

  • ES Modules - Modern JavaScript with full ES module support
  • TypeScript Support - Complete TypeScript definitions with full type safety
  • IntelliSense Ready - Excellent IDE support with comprehensive type definitions
  • Multiple Input Types - Text, password, number, select, checkbox
  • Validation - Built-in and custom validation support
  • Inquirer Compatible - Drop-in replacement API available
  • Zero Dependencies* - Only essential dependencies for terminal interaction

📦 Installation

npm install trompt

Requirements: Node.js ≥ 16.0.0

🚀 Quick Start

import { prompt } from 'trompt';

const name = await prompt('What is your name?');
console.log(`Hello, ${name}!`);

📚 API Reference

Basic Usage

import { prompt } from 'trompt';

// Simple text input
const answer = await prompt('Enter your name:');

// Configured prompt
const age = await prompt({
  type: 'number',
  question: 'Enter your age:',
  min: 0,
  max: 150,
  validate: (value) => value > 0
});

Prompt Types

Input (default)

const name = await prompt('Your name:');
const email = await prompt({
  type: 'input',
  question: 'Email:',
  validate: (value) => value.includes('@')
});

Password

const password = await prompt({
  type: 'password',
  question: 'Enter password:'
});

Number/Integer

const height = await prompt({
  type: 'number',
  question: 'Height:',
  suffix: 'cm',
  min: 0,
  max: 300
});

const count = await prompt({
  type: 'integer', // or 'int'
  question: 'How many items?'
});

Select (Single Choice)

const framework = await prompt({
  type: 'select', // or 'list'
  question: 'Choose framework:',
  choices: ['React', 'Vue', 'Angular', 'Svelte'],
  default: 0 // index of default choice
});

Checkbox (Multiple Choice)

const skills = await prompt({
  type: 'checkbox',
  question: 'Select skills:',
  choices: [
    'JavaScript',
    'Python', 
    'React',
    { text: 'Node.js', value: 'nodejs' },
    { text: 'TypeScript', value: 'ts', selected: true }
  ]
});

Inquirer Compatibility

import { inquirer } from 'trompt';

const answers = await inquirer.prompt([
  {
    name: 'username',
    question: 'Username:',
    type: 'input'
  },
  {
    name: 'framework',
    question: 'Framework:',
    type: 'select',
    choices: ['React', 'Vue', 'Angular']
  }
]);

console.log(answers.username, answers.framework);

🎯 Complete Example

import { prompt } from 'trompt';

async function collectUserData() {
  // Basic information
  const name = await prompt('What is your name?');
  const email = await prompt({
    type: 'input',
    question: 'Email address:',
    validate: (value) => value.includes('@') ? true : 'Please enter a valid email'
  });

  // Secure input
  const password = await prompt({
    type: 'password',
    question: 'Create a password:'
  });

  // Numeric input with validation
  const age = await prompt({
    type: 'number',
    question: 'Your age:',
    min: 13,
    max: 120,
    validate: (value) => value >= 13 ? true : 'Must be 13 or older'
  });

  // Single selection
  const role = await prompt({
    type: 'select',
    question: 'Select your role:',
    choices: [
      'Developer',
      'Designer', 
      'Product Manager',
      'Other'
    ]
  });

  // Multiple selection
  const technologies = await prompt({
    type: 'checkbox',
    question: 'Technologies you use:',
    choices: [
      'JavaScript',
      'TypeScript',
      'Python',
      'React',
      'Node.js',
      'Docker'
    ]
  });

  return {
    name,
    email,
    password,
    age,
    role,
    technologies
  };
}

const userData = await collectUserData();
console.log('User data:', userData);

🎯 TypeScript Support

Trompt includes comprehensive TypeScript definitions for full type safety and excellent IntelliSense:

import { prompt, inquirer, type InquirerQuestion } from 'trompt';

// Type-safe prompts with automatic return type inference
const name: string = await prompt('Your name:');

const age: number = await prompt({
  type: 'number',
  question: 'Your age:',
  min: 0,
  max: 150,
  validate: (value: number): boolean | string => {
    return value > 0 ? true : 'Age must be positive';
  }
});

const colors: string[] = await prompt({
  type: 'checkbox',
  question: 'Favorite colors:',
  choices: ['Red', 'Green', 'Blue']
});

// Inquirer-style with typed questions
const questions: InquirerQuestion[] = [
  {
    name: 'username',
    type: 'input',
    question: 'Username:',
    validate: (value: string) => value.length > 0
  },
  {
    name: 'framework',
    type: 'select',
    question: 'Framework:',
    choices: ['React', 'Vue', 'Angular']
  }
];

const answers = await inquirer.prompt(questions);
// answers.username and answers.framework are properly typed

Type Definitions

All prompt configurations are fully typed:

  • InputPromptConfig - Text input prompts
  • PasswordPromptConfig - Hidden password input
  • NumberPromptConfig - Number/integer input with validation
  • SelectPromptConfig - Single selection from choices
  • CheckboxPromptConfig - Multiple selection from choices
  • InquirerQuestion - Inquirer-style question objects

🔧 Configuration Options

| Option | Type | Description | |--------|------|-------------| | type | string | Prompt type: input, password, number, integer, select, checkbox | | question | string | The question to display | | message | string | Alias for question (inquirer compatibility) | | default | any | Default value | | validate | function | Validation function (value) => boolean \| string | | choices | array | Array of choices for select/checkbox | | min | number | Minimum value for numbers | | max | number | Maximum value for numbers | | suffix | string | Suffix to display after number input |

✅ What's New in v1.0

  • 🎯 ES Modules - Full ES module support with proper exports
  • 📝 Modern JavaScript - Updated to use modern JS features and best practices
  • 🛡️ Better Error Handling - Improved error messages and validation
  • 📚 TypeScript Ready - Comprehensive JSDoc annotations
  • 🔧 Enhanced API - More consistent and intuitive configuration
  • ⚡ Performance - Optimized for better performance and memory usage
  • 🎨 Better UX - Improved visual feedback and interaction