Moai Ref React Patterns logo

Moai Ref React Patterns

OrganizationPopular
modu-ai
moai-ref-react-patterns

React/Next.js component design patterns, state management strategies, and project structure reference for frontend development. Agent-extending skill that amplifies frontend domain work (spawned via Agent(general-purpose) with frontend instructions) with production-grade React patterns. NOT for: backend API design, database modeling, DevOps, mobile apps.

Overview

Publishermodu-ai
Repositorymoai-adk
Skill namemoai-ref-react-patterns
Stars
1.2K
Forks
226
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by modu-ai on GitHub. Read the source before you install it.

Installation

Install the Moai Ref React Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-react-patterns
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/modu-ai/moai-adk.git /tmp/moai-adk
mkdir -p .claude/skills
cp -r /tmp/moai-adk/.claude/skills/moai-ref-react-patterns .claude/skills/moai-ref-react-patterns
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Moai Ref React Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Moai Ref React Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Moai Ref React Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

React Patterns Reference

Target Spawn

Frontend domain work spawned via Agent(general-purpose) with frontend instructions - Applies these patterns directly to component design and state management.

Component Design Patterns

1. Compound Components

Parent and child share implicit state via Context.

Suited for: Tab, Accordion, Dropdown, Select Structure: <Select> + <Select.Trigger> + <Select.Option>

2. Custom Hooks (Extraction Pattern)

Extract state logic into reusable hooks.

Suited for: Form management, API calls, localStorage, debounce Naming: use prefix required - useForm, useDebounce, useAuth

3. Container/Presentational Separation

Separate data logic (Container) from UI (Presentational).

Suited for: Large apps, when testability is needed Container: Data fetch, state management, event handlers Presentational: Renders only from props, functionally pure

4. Headless Component

Provides behavior/state without UI.

Suited for: Design system-independent logic Examples: headless useCombobox, useDialog, useTable

State Management Selection Guide

State TypeToolRationale
UI LocaluseState, useReducerComponent-internal
Server StateReact Query / TanStack QueryCaching, refetch, optimistic
Global ClientZustandConcise, minimal boilerplate
Complex GlobalZustand + ImmerImmutability convenience
URL Statenuqs / useSearchParamsFilters, pagination
Form StateReact Hook Form + ZodIntegrated validation
Theme/i18nContext + ProviderLow change frequency

Decision Flow

Restorable from URL? -> URL state (nuqs)
Server data? -> React Query
Shared across components? -> Zustand
Component-internal? -> useState
Complex transitions? -> useReducer

Next.js App Router Structure

src/
├── app/                    # App Router
│   ├── (auth)/             # Auth route group
│   │   ├── login/page.tsx
│   │   └── register/page.tsx
│   ├── (main)/             # Main route group
│   │   ├── dashboard/page.tsx
│   │   └── settings/page.tsx
│   ├── api/                # API Routes
│   ├── layout.tsx          # Root layout
│   └── page.tsx            # Home
├── components/
│   ├── ui/                 # Base UI (Button, Input, Modal)
│   └── features/           # Feature components
│       ├── auth/
│       └── dashboard/
├── hooks/                  # Custom hooks
├── lib/                    # Utilities, config
├── stores/                 # Zustand stores
├── types/                  # TypeScript types
└── styles/                 # Global styles

Component Quality Standards

ItemStandard
Component SizeUnder 200 lines (split if exceeded)
Props5 or fewer (group into object if exceeded)
Custom HooksAlways extract when reusing logic
Error BoundariesSet at the page level
Loading StatesProvide loading UI for all async ops
Form ValidationValidate on both client and server

Performance Patterns

PatternWhenTool
MemoizationExpensive computationuseMemo, React.memo
Lazy LoadingBundle sizeReact.lazy, next/dynamic
Virtualization1000+ item lists@tanstack/react-virtual
Image OptimizationImage loadingnext/image
Optimistic UpdatesImmediate feedbackReact Query onMutate
DebounceSearch, inputuseDeferredValue or custom hook

Error Handling

Hierarchical Error Boundaries

RootErrorBoundary (global)
  └── LayoutErrorBoundary (per section)
      └── ComponentErrorFallback (individual)

API Error Handling

HTTP StatusClient Handling
401Auto logout + redirect
403Unauthorized UI
404Not Found page
422Per-field form error
429Retry + wait notice
500Generic error + retry button

Accessibility Checklist

  • Alt text on all images
  • Keyboard navigation (Tab, Enter, Escape)
  • ARIA labels (aria-label, role)
  • Color contrast 4.5:1 or above
  • Visible focus indicator
  • Semantic HTML (button, nav, main, section)

Common Rationalizations

RationalizationReality
"useEffect is fine for data fetching in React 19"React 19 provides use() and server components for data fetching. useEffect for fetch is a legacy pattern that causes waterfalls.
"Global state is simpler than prop drilling"Global state couples distant components. Prop drilling or composition via children is more predictable and testable.
"I will add TypeScript types later"Untyped components accumulate any-typed callers. Retrofitting types into a used component is much harder than starting typed.
"This component does not need memoization"Premature memoization is waste, but components rendering lists or expensive trees should be profiled, not assumed fast.
"CSS-in-JS is fine, everyone uses it"CSS-in-JS adds runtime overhead and bundle size. Tailwind or CSS Modules achieve the same scoping without the cost.

Red Flags

  • useEffect used for data fetching when server components or use() are available
  • Component receives more than 5 props without decomposition or object grouping
  • State management library used for server-cacheable data (use React Query or SWR instead)
  • Inline styles or hardcoded pixel values instead of design tokens
  • Component missing error boundary wrapping for async operations

Verification

  • Data fetching uses server components, use(), or React Query (not useEffect + fetch)
  • Components have TypeScript interfaces for all props
  • Error boundaries wrap components with async operations
  • Accessibility checklist completed (alt text, keyboard nav, ARIA, contrast, focus, semantics)
  • No inline styles or hardcoded color/spacing values (design tokens used)
  • Component renders correctly in React Strict Mode (no double-effect issues)

Frequently asked questions

What does the Moai Ref React Patterns AI skill do?

React/Next.js component design patterns, state management strategies, and project structure reference for frontend development. Agent-extending skill that amplifies frontend domain work (spawned via Agent(general-purpose) with frontend instructions) with production-grade React patterns. NOT for: backend API design, database modeling, DevOps, mobile apps.

Why use Moai Ref React Patterns on TypingMind?

Because you install it once and use it with any model. Moai Ref React Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Moai Ref React Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-react-patterns. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Moai Ref React Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Moai Ref React Patterns?

As many as you like. As long as a model supports skills, you can use Moai Ref React Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Moai Ref React Patterns AI skill free?

Yes. It is published on GitHub by modu-ai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇