How to Create a Basic CRUD App with StencilJS? A Comprehensive Tutorial
In this guide, you'll learn how to construct a basic CRUD (create, read, update, and delete) application using StencilJS.
This tutorial walks you through building a web app that executes essential operations to manage data effectively. We'll start by launching a Back4app project dubbed Basic-CRUD-App-StencilJS, which will serve as your robust backend.
Afterward, you'll design a scalable database by defining collections and fields—either manually or with assistance from the Back4app AI Agent. This step ensures that your database is tailored to support all CRUD operations reliably.
Next, you'll utilize the Back4app Admin App, an intuitive drag and drop interface, to manage your collections seamlessly. This no-code tool simplifies the handling of CRUD actions.
Finally, you'll connect your StencilJS frontend to Back4app via REST/GraphQL APIs. While the Parse SDK is available, we'll focus on API integrations which suit StencilJS perfectly, ensuring your backend remains secure through advanced access controls.
By the end of this tutorial, you'll have a production-ready web application that supports essential CRUD functions along with user authentication and robust data management.
- Master the process of building CRUD apps with a dependable backend system.
- Understand how to design a scalable backend and connect it with a StencilJS frontend.
- Learn to use a no-code admin tool (the Back4app Admin App) for efficient data operations.
- Discover deployment strategies, including Docker containerization, for launching your web application swiftly.
Before you get started, make sure you have:
- A Back4app account with an active project. Need assistance? Check out Getting Started with Back4app.
- A StencilJS development setup. Use the official StencilJS documentation to set up your environment. Ensure Node.js (v14 or later) is installed.
- Basic knowledge of JavaScript, web components, and REST APIs. Brush up on StencilJS concepts if necessary.
- Sign in to your Back4app account.
- Select the “New App” option from your dashboard.
- Name your project: Basic-CRUD-App-StencilJS and follow the on-screen instructions to complete the setup.

Once set up, your project will be visible on the dashboard, providing a solid base for your backend configuration.
For this CRUD application, you'll need to set up multiple collections. Below are sample collections along with their fields and data types to help you structure your database for efficient CRUD operations.
This collection holds details for each item.
Field | Data Type | Details |
---|---|---|
_id | ObjectId | Auto-generated primary key. |
title | String | Name or title of the item. |
description | String | Brief description of the item. |
created_at | Date | Timestamp when the item was created. |
updated_at | Date | Timestamp for the last update. |
This collection manages user profiles and authentication.
Field | Data Type | Details |
---|---|---|
_id | ObjectId | Auto-generated unique identifier. |
username | String | Unique identifier for the user. |
String | Unique email address. | |
password_hash | String | Encrypted password for authentication. |
created_at | Date | Account creation timestamp. |
updated_at | Date | Last updated timestamp for the user account. |
You can add these collections manually in the Back4app dashboard by creating a new class for each and adding columns with appropriate data types.

Follow the prompts to select a data type, specify a field name, set default values, and mark whether the field is mandatory.

The Back4app AI Agent is an innovative tool available within your dashboard that automates the generation of your database schema based on a simple prompt. This feature speeds up project setup and ensures your schema is aligned with your application needs.
- Access the AI Agent: Open your Back4app dashboard and find the AI Agent within the menu or under project settings.
- Input Your Schema Requirements: Provide a detailed prompt describing the collections and fields you require.
- Review and Confirm: Once the AI Agent processes your prompt, review the generated schema suggestions and apply them to your project.
This method ensures your schema is both consistent and optimized.
The Back4app Admin App offers a no-code interface that makes it simple to manage backend data. Its intuitive drag and drop system allows you to perform all CRUD operations—create, read, update, and delete—with ease.
- Open the “More” menu on your Back4app dashboard.
- Select “Admin App” and then click on “Enable Admin App.”
- Set up your admin credentials by creating an admin user. This process also configures default roles like B4aAdminUser and system collections.

Once activated, sign in to the Admin App to start managing your data.

Within this interface you can:
- Add Records: Click the “Add Record” option within any collection (e.g., Items) to create new entries.
- View and Edit Records: Select a record to inspect or modify its fields.
- Remove Records: Utilize the delete function to eliminate obsolete records.
This streamlined tool enhances the user experience by simplifying data management tasks.
With your backend configured and managed through the Admin App, the next step is to connect your StencilJS frontend to Back4app.
For StencilJS we'll focus on API integrations to keep things simple.
Integrate these API calls into your StencilJS components as needed.
If you prefer to use the Parse SDK, you can still integrate it within your StencilJS project since it’s a JavaScript library. However, our example here focuses on API calls.
Ensure data security by setting ACLs on your objects. For example, to create a private item:
Within the Back4app dashboard, set CLPs for each collection to ensure that only authorized users can access sensitive data.
Back4app uses Parse’s User class for managing authentication. In your StencilJS project, implement user registration and login as follows:
A similar structure can be applied for login and session management. You can also enable features like social logins, email verification, and password resets directly from the Back4app dashboard.
Back4app’s Web Deployment feature allows you to host your StencilJS application by deploying code directly from a GitHub repository.
- Open your project directory in a terminal.
Execute the build command:
- Confirm the Build: Ensure the www folder includes an index.html along with necessary CSS, JS, and image files.
Your repository should encompass all the source files for your StencilJS application. An example structure might be:
Initialize a Git repository in your project directory (if not already done):
Stage your files:
Commit your changes:
- Create a new GitHub repository: Name it something like Basic-CRUD-App-StencilJS-Frontend.
Push your code to GitHub:
- Access Web Deployment: Log into your Back4app dashboard, select your project (Basic-CRUD-App-StencilJS), and click on the Web Deployment section.
- Integrate GitHub: Connect your GitHub account following the provided instructions. This will enable Back4app to access your repository.
- Select the Repository and Branch: Choose your repository (e.g., Basic-CRUD-App-StencilJS-Frontend) and pick the appropriate branch (e.g., main).
Enter additional deployment details:
- Build Command: If your repository doesn’t include a pre-built www folder, specify a build command (e.g., npm run build). Back4app will execute this during deployment.
- Output Directory: Set the output directory to www so that Back4app knows where to locate your static files.
- Environment Variables: Add any required environment variables (e.g., API keys) in the deployment settings.
If you favor Docker for deployment, include a Dockerfile in your repository similar to:
Include this file in your repo and choose Docker deployment in Back4app.
- Initiate Deployment: Click the Deploy button after configuring your settings.
- Watch the Build Process: Back4app will fetch your code from GitHub, run the build command (if set), and deploy your containerized application.
- Access Your Application: Once deployed, Back4app will provide a URL where your StencilJS app is live.
- Visit the URL: Open the provided URL in your web browser.
- Test Functionality: Ensure the application loads properly, routes work correctly, and all assets (CSS, JS, images) are served without issues.
- Debug if Necessary: Use browser developer tools to inspect any errors. Check Back4app logs and verify GitHub and build configurations if issues occur.
Well done! You have successfully built a complete CRUD application using StencilJS and Back4app.
You set up a project titled Basic-CRUD-App-StencilJS, designed collections for Items and Users, and managed data with the Admin App.
Additionally, you connected your StencilJS frontend to your backend and implemented robust security measures.
Next Steps:
- Enhance the Frontend: Consider expanding your StencilJS app with advanced features such as detailed item views, search capabilities, and real-time notifications.
- Add More Functionalities: Integrate complex backend logic (e.g., Cloud Functions), third-party API integrations, or implement role-based permissions.
- Deepen Your Knowledge: Explore the Back4app documentation and other tutorials for further insights into performance tuning and custom integrations.
By following this tutorial, you've acquired the skills needed to create a robus
