Prerequisites
- Node.js 18+
- An asterai account
Overview
You’ll create a simple component that returns a greeting, then run it locally in an environment.Steps
1. Install the CLI
2. Authenticate
Generate an API key from your dashboard:3. Create a new component
4. Define the interface
Editplugin.wit to define your component’s interface. Replace your-username with your asterai username:
get-greeting, which takes a name and returns a greeting string.
5. Implement the component
Editsrc/index.ts:
6. Build
7. Push the component
Push your component to the registry:8. Create an environment
Create a new environment and add your component to it:9. Run locally
Run the environment locally:10. Call your function
In another terminal, call your component’s function:Hello, World!
11. Push to the cloud (optional)
To run your environment in the cloud, push it to the registry:What’s Next?
You’ve created a component and run it in an environment. From here you can:- Add more functions to your component
- Import other components from the registry
- Add configuration (environment variables, secrets) to your environment
- Compose multiple components in a single environment