How to Create a Custom Web Browser with Nyxt

Nyxt Web Browser Linux 00 Featured Image

Nyxt is a lightweight modern web browser that focuses on functionality, usability and extensibility. It borrows concepts from both Emacs and Vim to provide a way to navigate the web with only your keyboard.

This article aims to guide you through the process of installing the Nyxt browser on Ubuntu. Further, this article also aims to show you how you can configure Nyxt to fit to your own personal workflow.

Why Use the Nyxt Web Browser?

One of the main selling points of Nyxt is that it is easy to extend and modify. Unlike other modal browsers such as Qutebrowser, it is possible to configure every aspect and setting in Nyxt.

Nyxt Web Browser Linux 02 Default Landing Page

This is because the browser works as a live Lisp environment that you can actively tweak on the fly. For example, it is possible to configure the browser not to download any images from websites.

This makes Nyxt an incredibly versatile tool for power users that want to create a fully custom environment for web browsing.

Installing the Nyxt Web Browser

  1. The first step in installing Nyxt is to obtain a copy of its latest binaries from the developer’s website. You can do it from the terminal as well using wget:
wget https://github.com/atlas-engineer/nyxt/releases/download/2.2.4/nyxt-2.2.4.tar.xz
Nyxt Web Browser Linux 04 Download Browser Binary
  1. Create a new directory and extract the binary archive inside it. You can do both of those actions by running the following commands:
mkdir nyxt && mv nyxt-2.2.4.tar.xz ./nyxt
cd nyxt && tar xvf ./nyxt-2.2.4.tar.xz
Nyxt Web Browser Linux 05 Extract Browser Binary
  1. Create a symbolic link from your “nyxt” directory to “/usr/local/bin.” This adds Nyxt to your system’s PATH variable and enables you to open the browser from anywhere in your computer:
sudo ln -s /home/$USER/nyxt/usr/local/bin/nyxt /usr/local/bin/nyxt
Nyxt Web Browser Linux 06 Create Symbolic Link
  1. You can now run Nyxt by typing nyxt, then pressing Enter.
Nyxt Web Browser Linux 07 Browser First Run

Using the Nyxt Web Browser

With Nyxt up and running, you can now browse the internet with it. To open a webpage, you need to press Ctrl + L. This will bring up a small prompt where you can type the URL that you want to visit.

For example, pressing Ctrl + L, then typing “https://maketecheasier.com” will open the MakeTechEasier website.

Nyxt Web Browser Linux 08 Open Url

From here, the browser should properly display the website and you will be able to interact with it as a regular webpage.

Nyxt Web Browser Linux 09 Loaded Website

Similar to a regular web browser, you can also use the same interface to make basic search queries. For example, pressing Ctrl + L, then typing “maketecheasier linux tutorials” will open a DuckDuckGo results page.

Nyxt Web Browser Linux 10 Direct Search Browser

Navigating the Nyxt Buffer

By default, Nyxt does not support any form of browser tabs. Instead, it heavily relies on independent frames and buffers to maintain each webpage that it loads. This allows you to customize the behavior of Nyxt on a per-website basis.

Nyxt Web Browser Linux 11 Buffer Bar

You can access a list of all the available buffer in your current session by pressing Alt + Down.

Nyxt Web Browser Linux 12 Switch Buffer Menu

Aside from loading buffers from a list, you can also quickly switch in-between them by pressing Ctrl + Tab. This command will automatically cycle the browser to every buffer in the current session.

Nyxt Web Browser Linux 13 Go Back History

On the other hand, you can press Ctrl + [ to go back to the previous buffer and Ctrl + ] to go to the next one.

Lastly, the Nyxt browser also allows you to directly open webpages in separate buffers. Similar to opening in a background tab, you can do this by pressing Alt + L.

Nyxt Web Browser Linux 14 Open Page In Background

Navigating the Nyxt History

Another unique feature of Nyxt is its ability to display a tree-style history. This can be useful for users that want to trace back the sites that they have visited on their current session. To activate Nyxt’s tree-style history for the current buffer, press Ctrl + Space, then type “buffer-history-tree.”

Nyxt Web Browser Linux 15 Open History Tree

Nyxt also supports a traditional list-style system. Press Ctrl + Shift, then H to bring up a small dialog menu where you can search for the history item that you want to load.

Nyxt Web Browser Linux 22 History List Buffer

Lastly, you can also go through your session’s history similar to navigating your buffer list. For example, you can press Alt + [ to open the last page you have visited and Alt + ] to go back to your current webpage.

Changing Browser Modes in Nyxt

Nyxt ships with roughly 20 modes by default. These either control how the browser displays web content or change how you access a website. For example, the “noscript-mode” disables all JavaScript for the current buffer.

Nyxt Web Browser Linux 16 Enable Noscript Mode 1

In order to change a mode, you need to press Ctrl + Space. This will bring up a small dialog box where you can provide the name of the mode that you want to activate. In my case, I type “emacs-mode” to enable Emacs-like keybindings while browsing the web.

Nyxt Web Browser Linux 17 Enable Emacs Mode 1

Lastly, it is also possible to stack multiple modes in a single session. This can be helpful for users that want to create their own unique session while using Nyxt. To do this, you need to press Ctrl + Space, then type “toggle-modes.”

Nyxt Web Browser Linux 18 Enable Multi Mode 1

Configuring and Extending Nyxt

One of the biggest features of Nyxt is that it is possible to configure and extend almost every aspect of the program. However, it also means that it is possible to break the program with a wrong setting. With that in mind, you can create your own Nyxt configuration file by running the following command:

mkdir /home/$USER/.config/nyxt/ && touch /home/$USER/.config/nyxt/init.lisp
Nyxt Web Browser Linux 19 Create Configuration File 1

With a configuration file up and running, you can now write your own custom settings. For example, the following line of code will rebind the address buffer from Ctrl + L to Ctrl + Alt, then K:

(defvar *custom-keymap* (make-keymap "custom-map")
    "Keymap for `custom-mode'.")
 
(define-key *custom-keymap* "C-M-k" 'set-url)
 
(define-mode custom-mode ()
    "Mode for the custom key bindings in `*custom-keymap*'."
       ((keymap-scheme (keymap:make-scheme
                     scheme:cua *custom-keymap*
                     scheme:emacs *custom-keymap*
                     scheme:vi-normal *custom-keymap*))))
  • The defvar function tells Nyxt to create a custom keymap for the browser and name it as “custom-map.”
  • On the other hand, the define-key function creates a new keyboard combination inside that keymap and assigns it to the 'set-url function. In this case, the value C-M-k corresponds to Ctrl + Alt, then K.
  • Lastly, the define-mode function tells Nyxt to contain all the settings for the custom keymap inside a special “custom-mode.” This allows you to isolate any changes that you have made away from the default configuration.
Nyxt Web Browser Linux 20 Sample Configuration File 1

With that done, you can now apply your new settings by saving your config file and reloading the Nyxt browser.

Nyxt Web Browser Linux 21 Custom Mode Available

Frequently Asked Questions

Is it possible to run Nyxt without a terminal open?

Yes. It is possible to run the Nyxt browser without relying on the terminal. To do this, you can create a custom .desktop file for your Nyxt application.

I am getting a STRING INVALID error whenever I do any action in Nyxt.

This problem happens whenever you run Nyxt on a Wayland session. This is because the program heavily relies on Xorg to render and process its functions. You can fix this by logging out of your current session and selecting “Ubuntu on Xorg” on your machine’s login menu.

I can't launch the web browser due to a GTK/Xorg error.

This error mostly occurs whenever your system is out of date. You can fix this issue by running sudo apt update then sudo apt upgrade to bring all of your programs and libraries to their latest version.

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.