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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ink-mini-code-editor

v0.0.4

Published

Code editor for Ink library

Readme

ink-mini-code-editor

Code editor component with syntax highlighting for Ink CLI applications.

Install

npm install ink-mini-code-editor

Usage

import React, {useState} from 'react';
import {render, Box, Text} from 'ink';
import CodeEditor from 'ink-mini-code-editor';

const SQLEditor = () => {
	const [code, setCode] = useState('SELECT * FROM users WHERE id = 1');

	return (
		<Box flexDirection="column">
			<Text>SQL Query Editor:</Text>
			<Box>
				<Text>{'> '}</Text>
				<CodeEditor
					value={code}
					onChange={setCode}
					placeholder="Enter SQL query..."
					language="sql"
					onSubmit={(val) => {
						console.log('Submitted:', val);
					}}
				/>
			</Box>
		</Box>
	);
};

render(<SQLEditor />);

Props

value

Type: string

Value to display in the code editor.

placeholder

Type: string

Text to display when value is empty.

focus

Type: boolean
Default: true

Listen to user's input. Useful in case there are multiple input components at the same time and input must be "routed" to a specific component.

showCursor

Type: boolean
Default: true

Whether to show cursor and allow navigation inside the editor with arrow keys.

highlightPastedText

Type: boolean
Default: false

Highlight pasted text.

mask

Type: string

Replace all chars and mask the value. Useful for password inputs.

<CodeEditor value="secret" mask="*" />
//=> "******"

onChange

Type: Function

Function to call when value updates.

language

Type: string

Language for syntax highlighting (e.g., 'sql', 'javascript', 'python'). When not specified, no syntax highlighting is applied.

<CodeEditor value={code} onChange={setCode} language="sql" />

onSubmit

Type: Function

Function to call when Enter is pressed, where first argument is the value of the input.

getSuggestion

Type: (value: string) => string | undefined

Function that returns an autocomplete suggestion based on the current value. The suggestion should be the complete text (including what's already typed). When a valid suggestion is returned, a grey ghost text appears showing the remainder of the suggestion. Press the right arrow key to accept the suggestion.

const getSuggestion = (value) => {
	const commands = ['select * from users', 'insert into table', 'delete from table'];
	return commands.find(cmd => cmd.startsWith(value) && cmd !== value);
};

<CodeEditor value={code} onChange={setCode} getSuggestion={getSuggestion} />
// User types "sel" → displays: sel|ect * from users (grey ghost text)
// User presses → → value becomes "select * from users"

onSuggestionAccept

Type: (accepted: string) => void

Callback function called when a suggestion is accepted via the right arrow key. The accepted suggestion string is passed as the argument.

Uncontrolled usage

This component also exposes an uncontrolled version, which handles value changes for you. To receive the final input value, use onSubmit prop. Initial value can be specified via initialValue prop.

import React from 'react';
import {render, Box, Text} from 'ink';
import {UncontrolledTextInput} from 'ink-mini-code-editor';

const SQLEditor = () => {
	const handleSubmit = (query) => {
		// Execute query
	};

	return (
		<Box flexDirection="column">
			<Text>SQL Query Editor:</Text>
			<Box>
				<Text>{'> '}</Text>
				<UncontrolledTextInput
					initialValue="SELECT * FROM"
					placeholder="Enter SQL query..."
					onSubmit={handleSubmit}
				/>
			</Box>
		</Box>
	);
};

render(<SQLEditor />);

Development

Run the demo:

npm run dev

License

MIT