top of page

Building a Wix Custom Element Widget: A Comprehensive Guide

Updated: May 10

Overview of Wix Custom Element Widget Development


Navigating the complexities of Wix app development can be challenging. However, the principles outlined here represent a systematic approach to Wix Custom Element Widget development. This guide is grounded in practical experience and iterative learning.


After multiple iterations, I've distilled essential steps and structural insights for creating a Wix Custom Element Widget. The Wix Dev Node.js environment utilizes React with TypeScript integration. This ensures strong typing, enhancing the code's reliability and maintainability. Furthermore, leveraging Google Cloud Platform provides scalability for your development needs.


In this tutorial, we will build the foundation of a Wix Application Custom Element Widget. By the end, you will have a customizable template for future projects. Check out the Github Repo: my-wix-app.


Getting Started with Create Wix App


Initiating Create Wix App


This command initiates a structured approach to Wix app development, providing a systematic method for creating custom widgets.

Strategic App Generation Considerations


When prompted, select the following options:

  • App Type: Basic app for granular control

  • Widget Framework: Choose based on your project needs


The results from my selections were successful, as shown in the image below.


An image of the terminal output after Wix Basic App baseline Success.
Wix Basic App baseline Success, but this app needs an extension to be useful.

Extensibility Through the Wix Generator


Shows Terminal output after running the npm run generate wix cli command
Wix Generator Wix Application Extension Options.

This command provides structured options for expanding your Wix app.


You can generate directory structures for:

  • Site Widgets

  • Dashboard Pages

  • Backend Integrations

  • More...


Understanding the Wix App Directory Structure



The directory structure for `my-wix-app` will look like this:


```

my-wix-app/

├── src/

│ ├── site/widget/custom-elements/my-widget/

│ ├── dashboard/

│ ├── backend/

│ └── assets/

├── .wix/

├── dist/

└── node_modules/

```


Each directory serves a unique architectural purpose. The `site/widget/custom-elements/my-widget` directory is where all custom elements will be housed.


My Specific Custom Element Widget Implementation Directory Structure


Shows the Directory structure of this repository: https://github.com/tmanundercover/my-wix-app/
The generated Basic Application comes with a dashboard page.

Using This Repo as a Custom Element Template


Even though it adds a few more steps, I recommend using Create Wix App and the Wix Generator to start your widget. This ensures you have the latest and greatest directory structure.

An image of the terminal output after Wix Site Widget Generation Success
Wix App Generator Success! Your repo should look like my repo now BUT THAT'S NOT A GOOD THING yet

However, if you choose to use it as a template after setting up the repo in your local development environment, make sure to address the following:


UUID Management Read about it here


  • Generate unique identifiers systematically.

  • Replace the old UUID in the `elements.json` file. Now your widget will have a new ID for Wix.

  • Ensure consistent app identification.

  • Check the Repo script.

  • A new UUID command is included in `package.json`.


  • Change the UUID in the `element.json` file to this new unique identifier using the UUID Node package. Failing to do so may result in errors.


Local Development: Wix CLI Utilization


The CLI is a professional development tool that streamlines your workflow.

The Finale!


Custom Element Widgets provide a standardized approach to creating modular, reusable web components within the Wix ecosystem. By summarizing your steps and maintaining clean code, you can ensure long-term maintainability of your projects.


Now you are ready to begin developing your own new shiny Wix App Custom Widget. Please share your progress in the comments!


Code as though you will be the one to maintain it!

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page