How to work on an app from your machine
This guide shows you how to connect Picked to an app server that runs on your machine. You can then change the app and try each change in a project.
You need an app directory with a picked.config.ts file whose app section is the
manifest, and a server that uses @picked/app-kit. You also need the private key of the app, and a CLI that is signed in. Build and install your first app makes
all of these.
1. Start the server
Set the variables that the server reads, for the Picked environment that you use. The values for each environment are in App environment variables.
export PICKED_APP_PRIVATE_KEY='MC4CAQAwBQYDK2VwBCIEI…'
export PICKED_API_URL=https://api.picked.app
export APP_PUBLIC_URL=https://my-app.tunnel.example
export PICKED_DASHBOARD_ORIGINS=https://dashboard.picked.app,https://*.picked.app,https://dashboard.convincely.comStart the server. Keep it open while you work.
2. Make the port public
Forward the port of your server to a public https address with a forward tool of your
choice. Copy the address that the tool gives.
Picked sends requests only to a public host. The address must use https and the default
port. An address on localhost or on a private network works only with a Picked API on
your machine. Refer to
Work with a Picked API on your machine.
3. Deploy a dev version
In the app directory, deploy the manifest to the dev versions of the app. Give the public address as the endpoint:
npx picked app dev --endpoint https://my-app.tunnel.example --org acmeDeployed My App (my-app) dev version 3 [app_…]
The command does these things:
- It reads the
appsection ofpicked.config.ts,picked.config.jsorpicked.config.json, in that order. - It replaces the
endpointof the manifest with the value of--endpoint. - It moves each slot whose
urlstarts with theendpointin theappsection to the new endpoint. A slot on a different address keeps itsurl. - It registers the public key of
PICKED_APP_PRIVATE_KEYwith the app.
--endpoint is necessary. --org takes the slug or the ID of the organization. You can
leave it out when your account is in one organization only.
If the manifest has errors, the command shows each one below
picked.config `app` is not a valid app manifest: and deploys nothing.
When you deploy a handle for the first time, Picked makes the app. For this, you must have
the scope organization_apps/create. Each later deploy needs organization_apps/update.
4. Install the dev version
Install the app on a project of the organization that owns the app. Refer to How to install an app.
Only projects of the organization that owns the app can install a dev version. A new installation uses the newest dev version only while the app has no release version. When the app has a release version, a new installation uses the newest release version.
The installation shows the badge Dev while it uses a dev version.
Picked sends the installation to your server before it completes the installation. If your server
does not answer with a 2xx status, Picked removes the installation and shows
<name> did not accept the installation. When your server answered, the message ends with
(it answered <status>).
5. Send a change to the project
What you do depends on what you changed:
- Server code only. Restart the server. Picked does not keep your code, so you do not deploy.
- The manifest. Run
picked app devagain. Then upgrade the installation. - The public address. Run
picked app devagain with the new--endpoint. Then upgrade the installation. Until you upgrade, Picked sends requests to the old address.
If the manifest is the same as the newest dev version, the command writes no version:
My App (my-app) is unchanged: the manifest matches dev version 3 [app_…]
After a new dev version, the installation shows New version available. To upgrade it, refer to How to upgrade or uninstall an app.
An installation that uses a dev version upgrades only to the newest dev version. An installation that uses a release version upgrades only to the newest release version.
If your server does not accept the upgrade, Picked puts the installation back on its
previous version and shows <name> did not accept the upgrade.
Work with a Picked API on your machine
If the Picked API and the dashboard run on your machine, set their ports in place of the
two addresses. Remove PICKED_API_URL and PICKED_DASHBOARD_ORIGINS from the shell of the
server, because the server reads them before the ports:
unset PICKED_API_URL PICKED_DASHBOARD_ORIGINS
export PICKED_APP_PRIVATE_KEY='MC4CAQAwBQYDK2VwBCIEI…'
export API_PORT=3001
export DASHBOARD_PORT=5173The server then reads the public keys of Picked from http://localhost:$API_PORT. It lets
these two origins show its pages: http://localhost:$DASHBOARD_PORT and http://127.0.0.1:$DASHBOARD_PORT.
The CLI does not read API_PORT. Set PICKED_API_URL in the shell that runs the CLI, and
sign in again:
export PICKED_API_URL=http://localhost:3001
npx picked loginA Picked API outside production sends requests to localhost on any port. You need no
forward tool, and the endpoint can be the local address of your server:
npx picked app dev --endpoint http://localhost:4103Related
- CLI — every flag of
picked app dev. - App environment variables — every variable that the server reads.
- How to install an app — the consent window and the scopes that you must hold.
- How to upgrade or uninstall an app — move an installation to a new version.
- How to deploy an app — deploy a release version.
- About apps — versions, dev versions and installations.
