# Building and running a session

A session is the first product-specific component started on boot. The session
component is responsible for building a product's user experience.

## Booting into a session

To boot into a session, do the following:

1. For a session to run at boot you need to configure the product build with
   the session's URL. Identify the component URL for your session:

   <br />


         fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm
         
   <br />

   Replace the following:
   - <var translate="no">pkg-name</var>: the package name
   - <var translate="no">your_session.cm</var>: the name of your session, including the `.cm` extension.

   For more information, see
   [`fuchsia-pkg`](https://fuchsia.dev/docs/reference/components/url#fuchsia-pkg) and
   [Package name](https://fuchsia.dev/docs/concepts/packages/package_url#package-name).
2. Update your `//local/BUILD.gn` to include `product_assembly_overrides`.


       import("//build/assembly/developer_overrides.gni")

       assembly_developer_overrides("custom_session") {
       base_packages = [
         "//path/to/your/session"
       ]
       platform = {
         session = {
           enabled = true
         }
       }
       product = {
         session = {
           url = "fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm"
         }
       }
       }

3. Run the following command to include `your_session` in your base image and set
   the configuration values you defined in `//local:custom_session`.


       fx set product.board --assembly-override=//local:custom_session

   `fx list-products` and `fx list-boards` will show lists of the products and
   boards available to be used in the `fx set` command. For more information on
   `fx` commands see the [fx documentation](https://fuchsia.dev/docs/development/build/fx).
4. Rebuild and re-pave the device.

       fx build
       fx ota

   This causes `session_manager` to start and launch your session.

For a full explanation of building a session component, see [Writing a Hello
World Session](https://fuchsia.dev/docs/development/sessions/writing-a-hello-world-session).

## Launch a session from the command line

There are cases when you don't want your session to launch at boot but still
want to be able to launch it from the command line. `session_manager` needs
to be running to launch a session. The `session_manager` target
ensures `session_manager` itself starts, but does not autolaunch a session.

To launch a session from the command line, do the following:

1. Update your `//local/BUILD.gn` with `product_assembly_overrides` using `autolaunch`.


       import("//build/assembly/developer_overrides.gni")

       assembly_developer_overrides("custom_session") {
       base_packages = [
         "//path/to/your/session"
       ]
       platform = {
         session = {
           enabled = true
           autolaunch = false
         }
       }
       product = {
         session = {
           url = "fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm"
         }
       }
       }

2. Add the `session_manager` target in the base dependency set, in
   addition to the session target.


       fx set product.board --assembly-override=//local:custom_session

   `fx list-products` and `fx list-boards` will show lists of the products and
   boards available to be used in the `fx set` command. For more information on
   `fx` commands see the [fx documentation](https://fuchsia.dev/docs/development/build/fx).
3. Run the following command to rebuild and repave the device:

       fx build
       fx ota

   This causes `session_manager` to start without launching your session.
4. Your session can now be launched from the command line.

   Run the following command to launch your session:

       ffx session launch fuchsia-pkg://fuchsia.com/pkg-name#meta/your_session.cm

   For more information about the `ffx session` command, run
   `ffx session --help`. For more information about `ffx`, see the
   [`ffx documentation`](https://fuchsia.dev/docs/development/tools/ffx/overview).

[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/development/sessions/building-and-running-a-session.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/development/sessions/building-and-running-a-session.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/development/sessions/building-and-running-a-session.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/development/sessions/building-and-running-a-session.md "Edit the source code of this page")