Prerequisites
Make sure you’ve completed the installation steps before continuing.Create Your First App
Create the Counter component
Add the following to
app.js:app.js
Adjust the import path based on where your app is located relative to the GlyphUI installation. If your app is in a sibling directory to
glyphui/, use ../glyphui/packages/runtime/dist/glyphui.jsWhat You Built
Congratulations! You’ve created a working counter app. Let’s break down what each part does:Component Class
- Extends Component: All GlyphUI components extend the
Componentbase class - Initial State: The
initialStateobject defines the component’s starting state - State is accessible via
this.statethroughout the component
Event Handlers
- Methods define behavior for user interactions
this.setState()updates state and triggers a re-render- The component automatically updates the UI when state changes
Render Method
- h() function: Creates virtual DOM elements (like
React.createElement) - hFragment(): Groups multiple elements without a wrapper
- hString(): Creates text nodes
- Event binding:
on: { click: handler }attaches event listeners
Mounting
- Creates an instance of your component
- Mounts it to a DOM element to render the UI
Try a Different Example
Here’s a “Hello World” app with changing greetings:- Storing arrays in the component instance
- Cycling through values
- Applying CSS classes to elements
Explore More Examples
The GlyphUI repository includes several complete examples:Counter
Simple counter with increment/decrement
examples/counter/counter.htmlTodo App
Full todo app with state management
examples/vercel-todo/index.htmlTic-Tac-Toe
Game with complex state logic
examples/tictactoe/index.htmlLazy Loading
Code splitting with Suspense
examples/lazy-loading/index.htmlNext Steps
Now that you’ve built your first app, dive deeper into GlyphUI’s features:Virtual DOM
Learn how the h() function creates virtual elements
Components
Master component lifecycle and composition
State Management
Use stores for global state
Hooks
Use hooks for state and effects