Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inkish

npm

Build SSH apps with React!

Inkish is an SSH server secured by default that makes building SSH apps really easy with React. Inkish is built on ssh2 for ink and inspired by wish, enabling existing React CLI applications to be served over SSH

Install

npm install inkish ink react

Usage

import React, {useState, useEffect} from 'react';
import {render, Text} from 'ink';
import {startServer} from 'inkish'

const Counter = () => {
	const [counter, setCounter] = useState(0);

	useEffect(() => {
		const timer = setInterval(() => {
			setCounter(previousCounter => previousCounter + 1);
		}, 100);

		return () => {
			clearInterval(timer);
		};
	}, []);

	return <Text color="green">{counter} tests passed</Text>;
};

startServer(<Counter />, render);

Then connect to the server locally via

ssh -t localhost -p 2222 # or on WSL: ssh -t $(hostname).local -p 2222

Examples

There are examples for a simple Ink applications like a simple chat interface or a basic counter.

Running With SystemD

If you want to run a Inkish app with systemd, you can create the following file:

[Unit]
Description=My App
After=network.target

[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/home/myapp/
ExecStart=/usr/bin/node --import tsx myapp.tsx
Restart=on-failure

NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/home/myapp/.ssh

[Install]
WantedBy=multi-user.target

Once the app is configured properly, you can run:

# need to run this every time you change the unit file
sudo systemctl daemon-reload

# start/restart/stop/etc:
sudo systemctl start myapp

About

React for interactive SSH apps

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages