Create Your First AIUI Agent | AIUI | Rokid

Build a page that displays Hello, AIUI! in the browser. You need Node.js 20 or later and npm.

Create Your First AIUI Agent

Build a page that displays Hello, AIUI! in the browser. You need Node.js 20 or later and npm.

Create the Project

Run the following commands from the directory where you keep your projects. The first command creates hello-aiui with a starter app and home page.

npm create @yodaos-pkg/aiui-agent@latest hello-aiui
cd hello-aiui

Register the Home Page

In app.json, check that pages lists pages/index/index without a file extension. Keep the other fields generated by the scaffold.

{
  "pages": [
    "pages/index/index"
  ]
}

Write the Page

Replace the contents of pages/index/index.ink with the following code. In this file, <script setup> defines the message, <page> displays it, and <style> centers it.

<script setup>
export default {
  data: {
    message: 'Hello, AIUI!'
  }
};
</script>

<page>
  <view class="page">
    <text class="title">{{ message }}</text>
  </view>
</page>

<style>
.page {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.title {
  font-size: 28px;
  font-weight: 600;
}
</style>

Preview the Page

Install the AIX CLI and start the preview from hello-aiui. Keep the preview running and open the URL printed in the terminal.

npm install -g @yodaos-pkg/aix-cli
aix preview .

Look for Hello, AIUI! in the center of the page. If you see a different page, check the working directory and the pages entry in app.json. Press Ctrl+C in the terminal to stop the preview.

Add an Interaction

Continue with Build an Interactive Counter to update the display when a button is pressed.