Nostradamus Prophecy Machine

    TypeScript icon, indicating that this package has built-in type declarations

    0.0.1 • Public • Published


    A utility for manipulating a list of React children.

    When building a CLI-style interfaces this can be useful for adding and removing lines when the prompt is submitted. Each child receives an item prop that contains methods and properties related to navigating and transforming the list. By default only the first child is rendered. It's up to the child elements to call a method on props.item to update the list. The child elements can be insered dynamically, defined up-front or a mix of both.

    Basic Prompt/Output example

    Here's an exmaple that renders an input and a button. When the button is clicked, 2 components are added (not rendered) to the list by calling item.insert(/* ... */).next(). By chaining next() the next child is rendered, which is <Output value={value} />. By passing value to Output it can render something based on it. The only requirement for Output is to call at some point to show the next Prompt. This could be after fetching data, a user interaction, or right when the component mounts (useEffect(() =>, []).

    import React, { useState } from 'react'
    import { render } from 'react-dom'
    import Session from '@replit/clui-session';
    // Substitute for somehting more interesting!
    const useFetchData = (value) => {
      return value;
    const Output = (props) => {
      // Do something interesting with prompt input value
      const data = useFetchData(props.value);
      useEffect(() => {
        if (data) {
          // After data has loaded, call `next` to show next child (which is another Prompt)
      }, [data]);
      if (!data) {
        return <div>Loading...</div>;
      // Render output data
      return <div>output: ${data}</div>,
    const Prompt = (props) => {
      const [value, setValue] = useState('');
      const onClick = () => {
          <Output value={value} />,
          <Prompt />,
      return (
          <input value={value} onChange={e => setValue(}/>
          <button onClick={onClick}>run</button>
        <Prompt />
    /* After typing "hello session" and clicking run on the output
     * the component tree would look like
     * <Session>
     *   <Prompt />
     *   <Output value="hello session" />
     *   <Prompt />
     * </Session>


    Step is a utility component that automatically shows the next child by calling when the component mounts

      <Step><div>step 1</div></Step>
      <Step wait={2000}><div>step 2 (paused for 1 second)</div></Step>
      <Step wait={2000}><div>step 3 (paused for 1 second)</div></Step>
      <Step><div>step 4</div></Step>

    Do is a utility component the gives you access to item inline as a render prop.

        {item => <button onClick={}>next 1</button>}
        {item => <button onClick={}>next 2</button>}
        {item => <button onClick={}>next 3</button>}




    npm i @replit/clui-session

    DownloadsWeekly Downloads






    Unpacked Size

    25.7 kB

    Total Files


    Last publish


    • tobyho
    • brenoafb
    • krishkrosh
    • xiaoyiatreplit
    • giuseppeatreplit
    • vdoubleu
    • masad-frost
    • lincolnreplit
    • stkenned
    • jnnnthnn-at-replit
    • alex-jungle-cat
    • replitmatt
    • cbrewster
    • wadeatreplit
    • ltazmin_replit
    • jeremypress
    • moudy
    • schestakov
    • lhchavez
    • slmjkdbtl
    • lunaroyster