Blocks Code Snippets

Here are some useful short code snippets that you can use in any type of Blocks app. Copy, adapt the names to your app and make things work!

Get Billing information

Get billing information for an app instance on a site. For example, the package name, information about the free trial, and more.

Learn more about pricing in Blocks.

Backend

Add this code to a web.js file:

Copy

Frontend

Import the function in your fronted code:

Copy
See deprecated wix-application Velo example
Copy

Get widget properties in a panel

Use a custom panel to get the widget API properties.

Copy
See deprecated wix-widget Velo example
Copy

Learn more about connecting panel elements to properties:

Set widget properties in a panel

Use a custom panel to set the widget API properties.

Copy
See deprecated wix-widget Velo example
Copy

Learn more about connecting panel elements to properties:

Open a dashboard page from a panel

Create a link in a custom panel that opens the app dashboard page.

Backend:

Copy

Frontend:

Copy
See deprecated wix-application and wix-editor Velo example
Copy

Learn more about opening a dashboard page from a panel:

Create a link in a custom panel that opens the app's plan picker.

Backend:

Copy

Frontend:

Copy
See deprecated wix-application Velo example
Copy

Learn more about:

Access inner-widget properties from a panel

Get and set properties of a nested widget from a panel in the outer widget. Learn more

Copy
See deprecated wix-widget Velo example
Copy

Expand and collapse panel elements

Expand and collapse elements in a custom panel. Learn more

Copy

Query data from a CMS database collection

Use the SDK's data module to query collections in your app.

Copy
See deprecated wix-data Velo example
Copy

Learn more about managing collections in Blocks:

Did this help?