logo

Explore our examples

We've put together a set of examples that demonstrate Namespace's features. They're also a way to quickly try out the platform.

Clone the examples repository

$ git clone https://github.com/namespacelabs/examples.git
$ cd examples

Install the CLI tool

If you haven't installed the ns command yet, refer to the Getting Started page.

Setup your workstation for local development

Namespace manages development environments for you, whether locally or remotely in the cloud. For this example, we'll setup a local development environment, which includes our build infrastructure and Kubernetes, running within Docker (but don't worry, you don't need to manage it).

$ ns prepare local

Start a development session

Namespace provides a fast managed edit/refresh development workflow. You start a new development session by running ns dev which automatically:

  • Builds all the required servers.
  • Deploys servers to the development environment (local or remote).
  • Sets up port forwarding so that services exported by the servers are available from the local workstation.
  • Starts the Namespace Web UI (as an extra server) for debugging.
  • Watches source files and will rebuild/restart on changes (edit/refresh).

Start a development session for the services we've created for you.

# Within our examples repository:
$ ns dev multitier/01-simple/frontend
 
   Servers deployed:
 
    [] namespacelabs.dev/examples/multitier/01-simple/frontend took 9.4s
    [] namespacelabs.dev/examples/multitier/01-simple/apibackend took 8.4s
    [] namespacelabs.dev/examples/multitier/01-simple/postgres took 8.4s
 
  Connected to FileSync (for hot reload), took 28.363167ms.
 
   Development mode, services forwarded to 127.0.0.1:
 
    [] frontend/myweb
        http://myweb-3nm0df2bvjots889.dev.nslocal.host:40080/
 
   Namespace: web ui running at: http://127.0.0.1:4001
 
   Key bindings (l): pause logs (s): show support servers (q): quit

Let's do a few changes

  1. Open your local workspace in VS Code, or your favorite editor.
  2. Make a change to any of apibackend or frontend: it will be automatically delivered to your development environment, either hot-reloaded if web, or rebuilt and restarted if it's a Go change.

What's next?