React Native のセットアップ

Expo アプリを一度セットアップすれば、プライベートレジストリからどのモバイル画面やブロックもインストールできます。手順は無料の beUI Native ガイドと同じで、Pro アイテムのインストール先パスを加えています。

Expo SDK, React Native58, 0.88 with React 19
Reanimated and Worklets4.7 and 0.13
Gesture Handler3.3
React Native SVG15.16
Uniwind with Tailwind CSS1.12 with 4.3

1. ライブラリをインストールする

すべてのアイテムは Reanimated でアニメーションし、Uniwind でスタイルを適用します。SDK とバージョンが合うよう、Expo 経由でインストールしてください。Skia や Bottom Sheet など追加のライブラリが必要なアイテムもあり、それぞれのページに記載しています。

npx expo install react-native-reanimated react-native-worklets react-native-gesture-handler react-native-svg
npm install uniwind tailwindcss

2. Uniwind とテーマを設定する

Metro の設定を Uniwind でラップします。Expo の Babel プリセットには Worklets プラグインが含まれているため、Expo アプリでは Babel の変更は不要です。

JSmetro.config.js
const { getDefaultConfig } = require("expo/metro-config");
const { withUniwindConfig } = require("uniwind/metro");

const config = getDefaultConfig(__dirname);

// Uniwind must be the outermost wrapper.
module.exports = withUniwindConfig(config, {
  cssEntryFile: "./global.css",
  dtsFile: "./uniwind-types.d.ts",
});

プロジェクトのルートに global.css を作成します。テーマの import は初回インストール時に追加されるトークンを参照します。CSS をサブフォルダに置いている場合は、components 用の @source も追加してください。

CSSglobal.css
@import "tailwindcss";
@import "uniwind";
@import "./components/beui-pro/beui/styles/theme.css";

3. アプリをラップする

global.css を一度だけ import し、アプリを GestureHandlerRootView でラップします。スワイプ、ドラッグ、シートに必要です。

TSXapp/_layout.tsx
import "../global.css";

import { Stack } from "expo-router";
import { GestureHandlerRootView } from "react-native-gesture-handler";

export default function RootLayout() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Stack />
    </GestureHandlerRootView>
  );
}

4. レジストリに接続してインストールする

Expo アプリで shadcn CLI を使うには、完全な components.json が必要です。これをプロジェクトのルートに追加し、アカウントの BEUI_PRO_TOKEN を使ってインストールしてください。

JSONcomponents.json
{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "rsc": false,
  "tsx": true,
  "tailwind": {
    "config": "",
    "css": "global.css",
    "baseColor": "neutral",
    "cssVariables": true
  },
  "aliases": {
    "components": "@/components",
    "utils": "@/lib/utils",
    "lib": "@/lib",
    "hooks": "@/hooks"
  },
  "registries": {
    "@beui-pro": {
      "url": "https://pro.beui.dev/r/{name}.json",
      "headers": {
        "Authorization": "Bearer ${BEUI_PRO_TOKEN}"
      }
    }
  }
}
export BEUI_PRO_TOKEN="beui_live_xxxxxxxxxxxx"
npx shadcn@latest add @beui-pro/native-tab-bar

アイテムは、import する共有 beUI ファイルと並んで components/beui-pro に配置されます。ファイルで受け取りたい場合は、ダッシュボードから個別またはまとめてダウンロードできます。

global.css
metro.config.js
components.json
components/
  beui-pro/
    premium/
      blocks/tab-bar/
    beui/
      hooks/
      styles/
        motion.ts
        theme.css

5. Inter を読み込む(任意)

Pro アイテムは font-sans-medium などのクラスで文字を設定しています。デモ映像と同じ見た目にするには、global.css のテーマの後にこれらのフォントファミリーを追加し、レンダリング前に 4 つのウェイトを読み込んでください。省略するとシステムフォントが使われます。

npx expo install @expo-google-fonts/inter expo-font
CSSglobal.css
@theme {
  --font-sans: "Inter_400Regular";
  --font-sans-medium: "Inter_500Medium";
  --font-sans-semibold: "Inter_600SemiBold";
  --font-sans-bold: "Inter_700Bold";
}
TSXapp/_layout.tsx
import {
  Inter_400Regular,
  Inter_500Medium,
  Inter_600SemiBold,
  Inter_700Bold,
  useFonts,
} from "@expo-google-fonts/inter";

const [loaded] = useFonts({
  Inter_400Regular,
  Inter_500Medium,
  Inter_600SemiBold,
  Inter_700Bold,
});