Not that long ago Apple introduced trackpad and mouse support in iPadOS 13.4, so I decided to connect my Magic Mouse to my iPad Pro 11" (2018) and even though some apps didn't include real trackpad support yet, it worked like a charm! Even the hover and drag events worked in Safari!.
I decided to try running VS Code on the iPad, and with a mouse it worked almost flawlessly!
Quite a few people asked me how I did that and the answer is code-server.
code-server is VS Code running on a
remote server, accessible through the browser.
Try it out:
docker run -it -p 127.0.0.1:8080:8080 -v "$PWD:/home/coder/project" -u "$(id -u):$(id -g)" codercom/code-server:latest
- Code anywhere: Code on your Chromebook, tablet, and laptop with a consistent dev environment. Develop on a Linux machine and pick up from any device with a web browser.
- Server-powered: Take advantage of large cloud servers to speed up tests compilations, downloads, and more. Preserve battery life when you're on the go since all intensive computation runs on your server.
- 64-bit host.
- At least 1GB of RAM.
- 2 cores or more are recommended (1 core works but not optimally).
- Secure connection over HTTPS or localhost (required for service workers and clipboard support).
- For Linux: GLIBC 2.17 or later and GLIBCXX 3.4.15 or later.
Run over SSH
It works by running the language server (debugger and IntelliSense), extensions and the file system part in the cloud on a VPS, and rendering the UI in your browser. It is able to do that because VS Code is actually written using web technologies and packaged with Electron.
It can be a Mac Mini in your attic, a rented server from AWS or anything that runs Linux or macOS, some people have even tried using a Raspberry Pi with an iPad and it works like a charm.
Download the latest prebuilt binary from the GitHub Releases to your server. Untar/unzip it somewhere.
cd into the code-server directory. There will be an executable file called
Variant A. If you don't want to set up SSH forwarding (faster, more convenient, requires a registered domain, less secure)
First of all, get an SSL certificate
You can get one for free from Let's Encrypt using acme.sh. Their README is pretty easy to follow, so I won't get into much detail.
Then, you can run code-server with
PASSWORD="correct-horse-battery-staple" ./code-server --host 0.0.0.0 --port [PORT] --cert ~/.acme.sh/[DOMAIN]/[DOMAIN].cer --cert-key ~/.acme.sh/[DOMAIN]/[DOMAIN].key
Et voila! You can now open your browser, enter the password you set in the environment variable and code
In your SSH client, run
ssh -L [PORT]:localhost:[PORT] root@[YOUR SERVER]
An SSH session will open, where you can start code-server with
./code-server --host 127.0.0.1 --port [PORT] --auth none
http://localhost:[PORT] in your browser and code!
If you have a keyboard and a mouse, the experience is flawless... almost. Here are a few quirks:
- Custom fonts installed via iFont don’t work in Safari (fixed by loading them via CSS)
- Scrolling wheel doesn’t work in editor (arrow keys and scrollbar to the rescue)
- Lack of escape key (ctrl+[ works, or you can remap ESC and Caps Lock in iPadOS Settings)
Yeah! I am a backend developer by day, and it's great coding on an iPad. Frontenders will disagree because iPad Safari lacks devtools, but let's hope that will change in iPadOS 14 :)
This is my first article on dev.to and I'd love it if you share your feedback in the comments! Also, feel free to ask any questions :)
Level up every day