Deploy your first application to Application Frontend using CLI
- How to log in to Application Frontend Service using the CLI.
- How to create, deploy, and manage a simple “Hello World” application.
- Understand how application versions work in Application Frontend.
- Activate and manage different application versions using
afctl.
Prerequisites
- SAP Business Technology Platform subaccount
- Cloud Foundry environment enabled in subaccount
- Subscription to Application Frontend service
- Subscription to SAP Business Application Studio
- Step 1
Option 1 - Create SAP Business Application Studio Dev Space:
- Navigate to BTP Cockpit subaccount.
- Navigate to Services > Instances and Subscriptions
- In the Subscriptions table click on SAP Business Application Studio link.

- Click CreateDevSpace.
- Enter Dev Space name (e.g.
MyDevSpace). - Select SAP Fiori kind of application.
- Select Application Frontend Service CLI additional SAP extension.
- Click Create Dev Space.

Option 2 - Install Application Frontend CLI locally
Before you start, make sure you have the required tools installed locally.
- Verify that Node.js (version ≥ 22.6.0) is installed:
shellCopynode --versionNote: If you don’t have Node.js installed, download it from nodejs.org.
- Install the Application Frontend CLI (
afctl) globally using npm:
shellCopynpm install -g @sap/appfront-cli- Verify the installation:
shellCopyafctlYou should see the current CLI version printed in your terminal.
- Step 2
- Navigate to your BTP Cockpit subaccount with Application Frontend Service subscription.
- Go to Services > Instances and Subscriptions.
- In the Subscriptions table, click on Application Frontend Service.
- Copy the URI from the Application Frontend CLI section.
- Open your terminal (command line) on your local machine.
- Run the following command to log in to Application Frontend Service using the CLI. Replace
<URI>with your copied one.
shellCopyafctl login --sso --api '<URI>'Tip: You can see all supported login options using
afctl login --help- A new browser tab will open. Complete the login form with your user credentials if prompted.
- (Optional) Validate that you are logged in and your session is active:
shellCopyafctl config
- Step 3
- Create a directory named
hello-world.
This will be your application root directory. - Change your working directory to it:
shellCopycd <path_to_hello_world>- Initialize your application with minimal configuration:
shellCopyafctl init
Tip: Use the
-fflag to skip prompts and initialize with default name and version.
Example:
afctl init -f
This creates:
manifest.json— contains application name and versionxs-app.json— routing configuration
- Create an
index.htmlfile with the following content:
htmlCopy<html> <head> <style> body { display: grid; place-content: center; position: absolute; inset: 0; } </style> </head> <body> <h1>Hello World!</h1> </body> </html>- Update
xs-app.jsonto set the welcome file to/index.html:
jsonCopy{ "welcomeFile": "/index.html", "routes": [{ "source": ".*", "service": "app-front" }] }- Push your application to Application Frontend Service:
shellCopyafctl push
- List deployed applications and their URLs:
shellCopyafctl list
- Copy the URL of the hello-world app from the terminal output and open it in your browser. You should see Hello World! displayed in the middle of the page.
- Create a directory named
- Step 4
Application Frontend Service supports multiple versions of the same app to be deployed and accessed simultaneously. This allows previewing new versions before activation and publication under the main URL.
Let’s update and redeploy your app to see this in action.
- Update
xs-app.jsonto add a new route that returns JSON with logged-in user details:
jsonCopy{ "welcomeFile": "/index.html", "routes": [{ "source": "^/user-api/currentUser$", "service": "sap-approuter-userapi" }, { "source": ".*", "service": "app-front" }] }Route order matters — Application Frontend processes routes sequentially and uses the first match.
- Update
index.htmlto fetch and display the current user's first name:
htmlCopy<html> <head> <style> body { display: grid; place-content: center; position: absolute; inset: 0; } </style> </head> <body> <h1>Loading...</h1> <script> fetch('./user-api/currentUser', { credentials: 'include' }) .then(res => res.json()) .then(user => { const h1 = document.querySelector('h1'); h1.textContent = `Hello, ${user.firstname}!`; }); </script> </body> </html>- Update
manifest.jsonto bump the version:
jsonCopy{ "sap.app": { "id": "hello-world", "applicationVersion": { "version": "2.0.0" } } }- Deploy the new version without activating it:
shellCopyafctl push -n- List the application versions:
shellCopyafctl list hello-worldYou’ll see:
- One main application URL (stable, never changes)
- Multiple version-specific URLs for each version

- Refresh your browser tab with the main application URL — it still shows version 1.0.0.
- Open a new browser tab with the version 2.0.0 URL — you'll see your new greeting version ("Hello, {your name}!").
- Activate version
2.0.0:
shellCopyafctl activate hello-world 2.0.0- Refresh the main application URL again — it now serves the new version.
Congratulations! You successfully finished the Hello World Application Frontend exercise.
- Update