Wix Blocks is currently open to a limited number of users.
A namespace is a unique indicator of your app, in the format of:
Copy Code
@prefix/suffix
The prefix is either your account name or your company name. The suffix usually indicates your app name.
You need a namespace to:
- Import the app’s Velo backend and public functions in the Wix Editors.
- Reference your app’s collections both in the Velo code of Wix sites and in the app code in Blocks.
You don't need a namespace to:
- Create widget-only apps with no backend or public code, or collections).
Important Once you create a namespace you cannot change it.
There are two options for the prefix of your namespace. It can either start with your account name or with your company name.
Your account name is your Wix user name. If you are a Wix Partner, it's your Wix Partner account name. For this option, your namespace format is:
Copy Code
@your-account-name/your-app-name
Your company name is defined in your Company Info in the Wix Developers Center. Use this option if you plan to publish your app in the Wix App Market. For this option, your namespace format is:
Copy Code
@your-company-name/your-app-name
Company name requirements for namespace
- A company name that you put in your namespace must be unique in Wix. If someone used your company name and you think it might involve trademark infringement, please let us know.
- Your namespace can only include latin letters and numbers. If your company name includes non-latin letters, you'll need to change it in the Wix Developers Center to use it as the prefix of a namespace.
- If you change your company name in the Wix Developers Center, it will change the namespace of all future applications in your account.
You can change the suffix of your namespace as you wish. Just follow these requirements:
- Use only lower-case letters, and numbers.
- No special characters or spaces.
- Must be unique within your account.
To use your namespace for a collection, add the collection ID after the namespace, as shown here on line 11:
Copy Code
import wixData from 'wix-data';// ...let toInsert = {"title": "Mr.","first_name": "John","last_name": "Doe"};wixData.insert("@yourAccountName/yourApp/yourCollection", toInsert).then( (results) => {let item = results; //see item below} ).catch( (err) => {let errorMsg = err;} );
To import a public function from your app's code files, use this syntax:
import {yourFunctionName} from '@yourAccountName/yourAppName'
For example:
Copy Code
import {getStock} from '@nathanb257/stockquotesfromapi';$w.onReady(function (){getStock()});
To import from backend files, use this syntax:
import {yourFunctionName} from '@yourAccountName/yourAppName-backend'
For example:
Copy Code
import { getStock } from '@nathanb257/add1-backend';