> For the complete documentation index, see [llms.txt](https://support.marscat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.marscat.io/development-guide/frontend-development/basic-configuration.md).

# Basic Configuration

MarsApp frontend supports mainstream frameworks such as React and Vue, ensuring a good experience across various mobile devices. During development, if communication with RelayX is required, refer to the API interface descriptions.

Each MarsApp should have a unique icon named `icon.png`, with a recommended size of 192x192 pixels. After packaging, this icon should be placed in the project root directory to ensure the MarsApp icon displays correctly. The `icon.png` naming cannot be changed arbitrarily; if it is missing or named incorrectly, an exception will be prompted when publishing MarsApp.

Development must follow these project specifications:

{% stepper %}
{% step %}

### File Size

Ensure each packaged file (including resource files) is smaller than 4MB, and the entire ZIP package size does not exceed 10MB, to avoid affecting MarsApp's publishing and updating capabilities. RelayX Network will continue to expand network performance to support larger MarsApps in the future.
{% endstep %}

{% step %}

### File Naming

Each packaged file name can only contain letters (a-z, A-Z), numbers (0-9), underscores (\_), hyphens (-), and dots (.), and must comply with this naming convention.
{% endstep %}

{% step %}

### Resource Paths

Use relative paths when referencing local resources in the project, as absolute paths may cause resources to fail loading correctly.
{% endstep %}

{% step %}

### Function Limitations

Features that download resources to local files are disabled in RelayX.
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**Notes**

When using postMessage during frontend development, pay special attention:

1. **Avoid Conflicts**: When postMessage must be used in the project, add the `noRelayAPI` field in the postMessage parameters and set it to `true`, so that the frontend can use postMessage normally without conflicting with MarsApp API.

Correct usage:

{% code title="postMessage.js" %}

```javascript
window.parent.postMessage({
  type: 'my-app-message',
  data: { /* your business data */ },
  noRelayAPI: true  // Must add this field
}, '*');
```

{% endcode %}

2. **Message Listening**: When listening for postMessage, you need to filter out MarsApp API messages. Normal RelayApp API response message structure is:

{% code title="relay-api-response.json" %}

```json
{
  "code": 200,
  "cmd": "xxxx",
  "messageId": "0", 
  "result": {}
}
```

{% endcode %}

Recommended correct message listening method using unique message type identifiers:

{% code title="message-listener.js" %}

```javascript
window.addEventListener('message', (event) => {
  const message = event.data;
  
  // Filter out RelayApp API messages
  if (message && typeof message === 'object' && 
      ('code' in message && 'cmd' in message && 'messageId' in message)) {
    return; // This is a RelayApp API return message, ignore processing
  }
  
  // Handle custom application messages
  if (message.type === 'my-app-message') {
    // Process your application message
  }
});
```

{% endcode %}

3. **Important Reminders**:

* Must include `noRelayAPI: true` in all custom postMessage
* When listening for messages, prioritize filtering out MarsApp API messages with `code`, `cmd` and `messageId` fields
* Recommend defining dedicated message type prefixes for your application, such as `my-app-*`
  {% endhint %}
