Building a Sitevision WebApp from Scratch

This recipe guides you through creating and deploying a minimal Sitevision WebApp module using React.
By following the steps in this guide, you will build a simple module that renders a greeting message and displays it on a page in Sitevision. The recipe covers the complete workflow—from creating the project to publishing the module on a public page.
The goal of this recipe is not to build a complex application, but to help you understand the core development flow for Sitevision WebApps.
Level: Beginner
Estimated time: 30–60 minutes
Outcome: A working WebApp installed and published on a Sitevision site.
Id: recipe-001-create-and-publish-module
Version: 1.0
Prerequisites:
- Access to a Sitevision environment.
- Basic Javascript knowledge.
- Development environment configured.
- Permission to add and install modules on web site.
Step 1 — Create the project
Intent
Create a new Sitevision WebApp (React) project with the default project structure and development configuration.
Input
- An empty directory where the project will be created.
Output
- A new project folder:
hello-world-webapp - A generated project structure including required files (`manifest.json`, `src/index.js`, `src/main.js`)
Commands
Run the following command in your terminal:
CLI configuration
During project creation you will be prompted with a few questions. Use the following values:
Question | Answer |
|---|---|
What type of app do you want to create? | WebApp (React) |
Do you want to use TypeScript? | No |
Server-side rendering only? | No |
Development domain | Your development domain (or localhost) |
Development site name | Site name |
Development addon name | Hello World App |
Username for development site | Username |
Password for development site | ********* |
Use (unsafe) HTTP for local development | Yes, if running Sitevision locally, otherwise, No |
Verification
Run in terminal:
The following files must exist for a valid WebApp project:
Acceptance check
The step is successful when:
- The project folder opens correctly in your IDE
manifest.json, src/index.js, and src/main.js exist.dev_properties.jsonexists (used later for deployment with `npm run dev`)
Common issues
npx command not found
- Make sure Node.js and npm are installed.
Incorrect development settings
If needed, you can update the file .dev_properties.json after the project has been created.
Step 2 — Implement minimal rendering (Hello World)
Intent
Implement a minimal WebApp that server-side renders a React component and then hydrates it on the client so the module displays content on the page in Sitevision.
Input
- A WebApp project created in Step 1.
- The following files already exist:
Output
- A WebApp that renders:
The value name is retrieved from appData (it may be empty if not configured).
Architecture overview
The WebApp follows a simple SSR → Hydration architecture.
Rendering flow
Server-side rendering (index.js)
When a user loads the WebApp, a route handler renders the React component on the server using renderToString.
The server sends the HTML along with an initialState.
Client-side hydration (main.js)
When the page loads, React attaches event handling and state to the existing HTML using hydrateRoot.
UI component (App.js)
A React component displays the greeting message and the optional name.
2.1 Verify WebApp manifest
Goal
Ensure the WebApp metadata and dependencies are correctly defined.
Open manifest.json and verify that it contains at least the following fields:
Verification
- type is "WebApp"
- id and version exist
2.2 Implement server-side rendering
Goal
Render the React component on the server and return the HTML with the initial state.
Replace the contents of:
With:
Verification
router.get("/")existsres.agnosticRender()is used to send the HTML response
2.3 Implement client hydration
Goal
Attach React interactivity to the server-rendered HTML.
Replace the contents of:
With:
Verification
- hydrateRoot(el, ...) is used.
- initialState.message and initialState.name are passed to the component
2.4 Implement the UI component
Goal
Create a simple React component that displays the greeting message.
Replace the contents of:
With:
Verification
- The component renders {message} {name}
- App is exported as default
Acceptance check
Step 2 is complete when:
- manifest.json contains valid WebApp metadata
- src/index.js renders the component using agnosticRender
- src/main.js hydrates the React app using hydrateRoot
- src/components/App.js renders the greeting message
Step 3 — Build and package the WebApp
Intent
Build the WebApp and generate a deployable artifact that can be uploaded and installed in Sitevision.
Input
- A WebApp project with implemented rendering logic (from Step 2)
- Source code located in:
Output
A compiled WebApp artifact:
This `.zip` file is the deployable WebApp package that will be installed in Sitevision.
Build process overview
During the build process:
The build script:
- bundles JavaScript and CSS
- prepares the WebApp for deployment
- creates a `.zip` artifact
3.1 Run the build script
From the project root, run:
The build script compiles the source code and packages the WebApp.
3.2 Verify build output
After the build finishes, verify that a dist directory exists in the project root.
Run:
Expected output:
hello-world-webapp.zip
The file: hello-world-webapp.zip is the WebApp artifact created by the build process.
Verification
Confirm the following:
- The build command runs without errors.
- A
dist/folder exists. - The file
hello-world-webapp.zipis created.
Acceptance check
Step 3 is successful when:
- The build process completes successfully
- The
dist/directory exists - A deployable WebApp artifact (
.zip) is generated
Step 4 — Install the WebApp in Sitevision
Intent
Deploy and install the WebApp in your Sitevision environment so it becomes available as a module that can be placed on a page.
Input
- A built WebApp artifact from Step 3
- A configured development environment
- The configuration file:
.dev_properties.json
Output
- An Addon container created in Sitevision
- A deployed WebApp version uploaded to the Sitevision repository
- The module available in the Module selector
Concept: Addons and WebApps
In Sitevision, a WebApp must belong to an Addon.
The Addon acts as a container that can store multiple versions of the same WebApp.
Prerequisites
Before deploying, verify the following:
1. Development configuration exists
The file below must exist and contain valid credentials:
.dev_properties.json
Example configuration:
2. REST API access is enabled
The Sitevision site must allow REST requests.
Enable this in:
Site Settings → REST API
4.1 Create the Addon container
Create the Addon in Sitevision using the deployment script.
Run:
Expected response:
This creates the Addon container that will store WebApp versions.
4.2 Deploy the WebApp
Once the Addon exists, deploy the WebApp to the environment.
Run:
The script will:
- Upload the WebApp to Sitevision.
- Deploy a new version.
- Watch the project files.
- Automatically redeploy when files change and overwrite the current version.
Expected response:
Verification
Verify that the WebApp exists in Sitevision.
Open the Sitevision edit interface and navigate to:
Addons view
Confirm that:
- The Addon exists.
- The WebApp version is uploaded.
Acceptance check
Step 4 is successful when:
- The Addon container exists in Sitevision.
- A WebApp version is uploaded.
- No errors appear in the deployment output.
Common issues
Authentication failure
- Check credentials in:
.dev_properties.json
REST API calls blocked
Enable REST requests in: Site Settings → REST API
Step 5 — Place the module on a page
Intent
Add the deployed WebApp module to a page in the Sitevision editor so it can render content.
Input
- A deployed WebApp from Step 4.
- Access to the Sitevision editor
- A page where the module can be placed
Output
- The WebApp module added to a content area on a page.
- The module renders content in edit mode / preview
5.1 Open the Sitevision editor
Log in to Sitevision and open a page in edit mode.
Example navigation:
Website → Edit → Select page → Add module
5.2 Open the Module selector
In the editor toolbar, open the Module selector.
You can find modules in two ways:
- Search for the module by name
- Browse modules by category
Search for the module you deployed earlier, for example: "Hello World WebApp"
5.3 Add the module to the page
When the module is added:
- The WebApp configuration panel will appear.
- Default configuration values are loaded.
These configuration settings were generated by the create-sitevision-app boilerplate.
Configuration customization will be covered in a later recipe.
Verification
Confirm the following:
The module appears in the content area.
The module renders content in the editor.
The text `Hello, world!` (and optional name) is visible in preview
Acceptance check
Step 5 is successful when:
- The module can be added to the page.
- The module renders content in edit mode / preview.
Step 6 — Publish the page
Intent
Publish the page so the WebApp module becomes visible on the public website.
Input
- A page containing the WebApp module (from Step 5).
Output
- The page is published.
- The module renders on the public URL.
6.1 Publish the page
In the Sitevision editor, click: Publish
6.2 Open the public page
Open the public URL of the page in your browser.
Example: https://example.sitevision.se/page
Verification
Confirm that:
- The page loads successfully
- The module renders the greeting message
Expected output example:
Hello, world!
or
Hello, world! John Doe