Install your storefront on the server
Install your Nuxt, React or SvelteKit storefront from its npm package with one command, or create the project yourself and run the install command of the basklee-nuxt, basklee-react or basklee-svelte package. Either way the storefront is built on the server, runs as a system service that starts with the server and restarts after a failure, and its domains are connected with HTTPS. Choose your package below.
How it works
Each storefront gets its own service named basklee- followed by the storefront name, on a free local port from 3000. The service runs as the basklee user and reads the domain mapping files on every request, so a new domain needs no restart. nginx passes the requests of each domain to the storefront that serves it.
1 Install from npm with one command
Prepare the server first. Then run:
sudo basklee app install reactThe command asks for the storefront name (shop by default), your personal backend and the storefront domain, and shows what it will install. It adds the domain with its certificate first, so a DNS problem shows up before the build. Then it creates the project from the newest release of the package in /srv/basklee/shop, installs the dependencies, connects the backend and the domain and runs the install command described below. If a step fails, fix the problem and run the same command again: it continues in the same folder.
Give the answers as options to run it without questions:
sudo basklee app install react shop \
--domain shop.example.com \
--backend my-shop.orionplace.app| Option | What it does |
|---|---|
--version <version> | Package version, version range or tag. By default latest, the newest release. |
--domain <domain> | Storefront domain. Without it the command asks. |
--backend <name.orionplace.app> | Personal backend domain from your basklee.com profile. Without it the command asks. |
--port <port> | Local port of the service. By default the first free port from 3000. |
--www / --no-www | Also serve the www name of the domain and redirect it to the domain (--www), or not (--no-www). By default yes for example.com, no for shop.example.com. |
--skip-dns-check | Skip the DNS check, for example when a proxy in front of the server answers for the domain. |
--yes | Take the defaults instead of asking questions. |
List the published versions of the package, or install one of them (0.3.0 or newer). The project then keeps exactly that version:
sudo basklee app versions react
sudo basklee app install react --version 0.3.02 Or create the storefront yourself
To go step by step instead, create the project in /srv/basklee, the folder that setup prepared for storefronts:
cd /srv/basklee
sudo npx --yes basklee-react init shop
cd shop
sudo npm installTo install a project you already have, copy it to a folder such as /srv/basklee/shop (for example with git clone) and run sudo npm install in it. The service user cannot read a project in /root or another closed folder.
3 Connect your backend and domain
Use the personal backend domain from your basklee.com profile and your storefront domain. You can skip this step: install asks for both when they are missing.
sudo npx basklee-react set backend my-shop.orionplace.app
sudo npx basklee-react add frontend shop.example.com4 Install as a service
In the project folder run:
sudo npx basklee-react installInstall builds the project with npm run build, creates the service that runs next start with your .env, starts it and waits until the storefront answers. Then it runs basklee domain add for each storefront domain, which sets up nginx, the certificate and the domain mapping.
At the end it prints the address of each domain, for example https://shop.example.com. If a domain is not connected, usually because its DNS record does not point to the server yet, fix that and run sudo basklee domain add shop.example.com. A failed build leaves the running service unchanged.
5 Update and redeploy
After you change the code or update the package, run install again. It rebuilds the storefront and restarts the service on the same port:
sudo npx basklee-react update
sudo npx basklee-react installTo serve one more domain, add it to the project and run install again:
sudo npx basklee-react add frontend shop2.example.com
sudo npx basklee-react install6 Manage the service
Manage the service from the project folder with the package command. restart waits until the storefront answers again and shows the last log lines when it does not:
cd /srv/basklee/shop
npx basklee-react status
sudo npx basklee-react logs 200
sudo npx basklee-react restart| Command | What it does |
|---|---|
npx basklee-react status | Whether the service runs and starts with the server, its local port, whether the home page answers and the storefront domains. Ends with code 3 when the storefront is stopped or does not answer. |
sudo npx basklee-react start | Start the service and wait until the home page answers. |
sudo npx basklee-react stop | Stop the service. Its domains do not answer until you start it again. |
sudo npx basklee-react restart | Restart the service, for example after you change .env, and wait until the home page answers. |
sudo npx basklee-react logs [lines] [--follow] | The last log lines, 100 by default. With --follow new lines keep coming until you press Ctrl+C. |
npx basklee-react list | Every storefront service on this server with its type, port and state. |
sudo npx basklee-react uninstall [--dry-run] [--yes] | Stop the service, take it out of autostart and delete its unit file and registration; cleanup does the same. The project folder and its build stay. With the server tool it runs basklee app remove, which also turns the domains into a placeholder page. --dry-run shows what it would remove, --yes skips the question. |
The commands find the service by the project folder. From another folder, give its name. start, stop, restart, logs and uninstall need sudo; status and list do not:
sudo npx basklee-react restart --name shopThe server tool does the same by storefront name from any folder:
sudo basklee app list
sudo basklee app logs shop
sudo basklee app restart shop7 Install options
| Option | What it does |
|---|---|
--name <service> | Service name. By default the name of the project folder, for example shop. |
--port <port> | Local port. By default the first free port from 3000; later runs keep it. |
--user <user> | System user that runs the service. By default the owner of the folder, or basklee when the folder belongs to root. |
--no-build | Install the build that is already in the folder instead of building again, for example one built on another computer. Without a build the project is built anyway. |
--no-domains | Build and restart without connecting the domains. |
--yes | Take the defaults instead of asking questions. |
--dry-run | Show the planned service; nothing changes. |
With --dry-run install shows the service it would create and changes nothing:
sudo npx basklee-react install --dry-run
sudo npx basklee-react install --name shop --port 3000
sudo npx basklee-react install --no-domains