@codewithbeto/ui

中文文档
55.0.0发布于 2026/02/24MITTypeScriptCommonJS零依赖近 30 天下载 2052

A React Native UI component library built for Expo applications.

原始使用文档
文档目录18 节
  1. Overview
  2. Installation
  3. Quick Start
  4. Components
  5. Development
  6. Local Development Setup
  7. Building
  8. Type Checking
  9. Publishing
  10. How It Works
  11. Versioning
  12. Publishing a Stable Release
  13. Publishing a Beta Release
  14. Promoting Beta to Stable
  15. Example: Full Release Lifecycle
  16. Package Configuration
  17. Adding New Components
  18. License

@codewithbeto/ui

A React Native UI component library built for Expo applications.

Overview

This package provides reusable UI components for React Native applications. Components are built on top of React Native primitives and are designed to work seamlessly with Expo.

Installation

pnpm add @codewithbeto/ui

Or with npm:

npm install @codewithbeto/ui

Quick Start

import { Text } from "@codewithbeto/ui";

export default function App() {
  return <Text type="title">Hello World</Text>;
}

Components

  • Text - Lightweight text component with multiple size variants and full React Native Text compatibility

Development

Local Development Setup

This package is part of a pnpm workspace. For local development:

  1. Clone the repository and install dependencies:

    pnpm install
    
  2. Use the workspace link in apps/example to test your changes:

    import { Text } from "@codewithbeto/ui";
    
  3. Changes will hot-reload automatically in Expo.

Building

Before publishing, you must build the package to compile TypeScript to JavaScript:

pnpm --filter @codewithbeto/ui build

This command:

  • Compiles TypeScript files from src/ to JavaScript in dist/
  • Generates TypeScript declaration files (.d.ts) for type support
  • Creates source maps for debugging

Why build? We publish compiled JavaScript to npm, not TypeScript source files. This ensures:

  • Faster installs (no compilation needed)
  • Smaller package size
  • Better compatibility across different TypeScript versions

Type Checking

Run type checking without building:

pnpm --filter @codewithbeto/ui typecheck

Publishing

Publishing is automated via GitHub Actions. No local .npmrc or Personal Access Token is required.

How It Works

The repository includes a publish workflow that:

  • Triggers automatically when a GitHub Release is created
  • Publishes as latest for stable releases, or beta for pre-releases
  • Builds the package and publishes it to npm
  • Uses an NPM_TOKEN repository secret for authentication

Versioning

This package follows the Expo SDK versioning scheme. The major version matches the Expo SDK version it's built and tested against. For example, @codewithbeto/[email protected] is designed for Expo SDK 55. This makes it easy to identify at a glance that your packages are compatible with your SDK version.

Within a major version, we use patch bumps for bug fixes and minor bumps for new features:

  • Patch (55.0.0 → 55.0.1): Bug fixes, small improvements
  • Minor (55.0.0 → 55.1.0): New features (backward compatible)

Publishing a Stable Release

  1. Bump the version in package.json.

  2. Commit the version bump and push to main.

  3. Create a GitHub Release:

    • Go to the Releases page
    • Click "Draft a new release"
    • Create a new tag matching the version (e.g., v55.0.0)
    • Add release notes describing the changes
    • Click "Publish release"
  4. The workflow will automatically build and publish the package under the latest tag.

Publishing a Beta Release

Beta releases let you test new changes without affecting users on the stable version.

  1. Bump the version with a prerelease identifier, e.g. 55.0.0-beta.1.

  2. Commit the version bump and push to your branch.

  3. Create a GitHub Release:

    • Go to the Releases page
    • Create a new tag matching the version (e.g., v55.0.0-beta.1)
    • Check the "Set as a pre-release" checkbox
    • Click "Publish release"
  4. The workflow detects the pre-release flag and publishes under the beta dist-tag instead of latest.

Installing a beta version:

pnpm add @codewithbeto/ui@beta

Users who run pnpm add @codewithbeto/ui (without @beta) will continue to get the latest stable version.

Promoting Beta to Stable

Once a beta has been tested and is ready for production:

  1. Update the version in package.json to the stable version (remove the prerelease identifier):

    • 55.0.0-beta.3 → 55.0.0
  2. Commit the version bump and push to main.

  3. Create a regular GitHub Release (do not check "Set as a pre-release"):

    • Create a new tag matching the stable version (e.g., v55.0.0)
    • Click "Publish release"
  4. The workflow publishes the package under latest. All users will get the stable version on their next install or update.

Example: Full Release Lifecycle

Here's a typical workflow from development to stable release:

StepVersion in package.jsonGit TagPre-release?Dist-tag
First beta55.0.0-beta.1v55.0.0-beta.1Yesbeta
Fix a bug in beta55.0.0-beta.2v55.0.0-beta.2Yesbeta
Promote to stable55.0.0v55.0.0Nolatest

You can also trigger the workflow manually from the Actions tab with a custom dist-tag if needed.

Package Configuration

The package is configured to publish to npm:

  • Registry: https://registry.npmjs.org
  • Scope: @codewithbeto
  • Access: Public
  • Files included: Only the dist/ folder (specified in package.json)

Adding New Components

Follow this structure when adding new components:

  1. Create a new folder in src/components/:

    src/components/MyComponent/
    ├── MyComponent.tsx    # Component implementation
    ├── README.md          # Component documentation
    └── index.ts           # Exports
    
  2. Create the component with TypeScript:

    // src/components/MyComponent/MyComponent.tsx
    import { View } from "react-native";
    
    export interface MyComponentProps {
      // your props
    }
    
    export function MyComponent({ ...props }: MyComponentProps) {
      return <View>...</View>;
    }
    
  3. Create the component index file:

    // src/components/MyComponent/index.ts
    export { MyComponent, type MyComponentProps } from "./MyComponent";
    
  4. Export from the main src/index.ts:

    export { MyComponent, type MyComponentProps } from "./components/MyComponent";
    
  5. Add comprehensive documentation to the component's README.md including:

    • Component description and features
    • Props table with types and descriptions
    • Usage examples
    • TypeScript examples
  6. Update the Components section above with a link to your new component's README.

  7. Test in apps/example before publishing.

License

This package is licensed under the MIT License.

版本与发布记录

@codewithbeto/ui 共发布 3 个版本,首次发布于 2026/02/08;过去 12 个月发布了 3 个版本。

版本发布日期距今
55.0.0latest2026/02/248 个月前
0.0.22026/02/089 个月前
0.0.2-beta.1beta2026/02/089 个月前

关于 @codewithbeto/ui 的常见问题

@codewithbeto/ui 是什么?

A React Native UI component library built for Expo applications.

如何安装 @codewithbeto/ui?

在项目目录运行 npm install @codewithbeto/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)、expo(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codewithbeto/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codewithbeto/ui 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codewithbeto/ui 可以商用吗?

@codewithbeto/ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codewithbeto/ui 的下载量有多少?

根据 npm 官方下载统计,@codewithbeto/ui 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,052 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codewithbeto/ui 还在维护吗?

最新版本 55.0.0 发布于 2026/02/24(8 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/02/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。