---
title: Adapt to Platforms
---

# Adapt to Platforms

## Homogeneous files

You can write the programming logic by using different file extensions in your project to adapt to a specific platform.

- `.tsx` universally used
- `.web.tsx` web application
- `.mini.tsx` miniApp
  - `.wechat.tsx` WeChat MiniApp
  - `.tuya.tsx` Smart MiniApp
  <!-- - `.native.tsx` React Native 平台
  - `.ios.tsx` React Native iOS 端
  - `.android.tsx` React Native Android 端 -->

You can use the `--target` parameter in the command-line interface (CLI) to specify the platform for which your miniapp will be built and debugged. Then, the project files will be loaded sequentially from bottom to top in the preceding structure.

## Runtime

Differentiate environment variables by runtime.

```js
import {
  isWeb,
  isWechat,
  isTuya,
  isMiniProgram,
  isIOS,
  isAndroid,
  isNative,
} from '@ray-js/env';
```

Example:

```js
import { isTuya, isWechat } from '@ray-js/env';

export function say() {
  if (isTuya) {
    // Logic of Smart MiniApp
  } else if (isWechat) {
    // Logic of WeChat MiniApp
  } else {
    //
  }
}
```
