# Run Mode ## Function `app.mode` Controls how `bt_app` prepares resources, executes scripts, and loads window entries. Currently only `static`, `server`, and `remote` are supported. ## Compare | Mode | Entry example | Whether local service is required | Whether it is suitable for packaging | Suitable for scenarios | |---|---|---|---|---| | `static` | `index.html` | No | Yes | Pure static pages, gadgets, local resource applications | | | Yes | BT backend plus Web front-end desktop application | | `remote` | `https://example.com` | No | Yes | Remote Web, SaaS management tool, cloud page shell | ## static `static` mode reads project resources through `bt://app/...`. ```json { "app": { "mode": "static", "entry": "index.html" } } ``` The advantage is that it is simple to deploy and does not need to start the local web service after packaging. The disadvantage is that the page cannot rely on the browser server environment characteristics. For example, server-side routing needs to be handled by the front-end itself. ## server `server` mode first executes `server.bt` in the project root directory, and then opens the HTTP address specified by `app.entry`. ```json { "app": { "mode": "server", "entry": "http://127.0.0.1:18280" } } ``` `server.bt` Example: ```bt net.listen({ type:'web', bind:'127.0.0.1:18280', sites:[ { domains:['127.0.0.1'], root:'www/', entry:'main.bt', static:{ route:'/static/{**}', path:'www/static/', default:'index.html' } } ] }) ``` The advantage is that you can use the full BT Web service capabilities. The disadvantage is that the port must be managed, and the startup will fail if the port is occupied. After modifying `server.bt` or related resources while the development directory is running, `bt_app` will first stop the old web service, then re-execute `server.bt` and refresh the window. When modifying the listening port, `app.entry` needs to be modified simultaneously, otherwise the window will still open the old address. ## remote `remote` mode directly opens the remote URL: ```json { "app": { "mode": "remote", "entry": "https://example.com" } } ``` In remote entry mode, the software shell itself can remain stable, and the business page is deployed on the server side. After the developer updates the server content, the user can use the new version of the app again and does not necessarily need to re-download and install the client. The current version of the `remote` page will also inject `window.bt` and window control capabilities, and only trusted remote pages should be loaded. ## server.bt automatically executes In addition to `server` mode, as long as `server.bt` exists in the project resources, the current runtime will also try to execute it. If a normal `static` or `remote` project does not require local services, do not place useless `server.bt`.