Λογότυπο Vite React

Vite React

Κοινότητα
scottdurow
vite-react

Best practices for Vite + React + TypeScript web applications. Covers feature-first project structure, build/lint validation workflows, Vite configuration, and single-file build for embedding. For service layer patterns, domain models/DTOs, React Query integration, and error handling, see the `ioc-development-pattern` skill. For Fluent UI v9 component patterns, styling, and theming, see the `ui-fluentui-react` skill. Triggers on "vite", "react app", "feature structure", "vite build", "react typescript", "single file build", "vite config".

Επισκόπηση

Εκδότηςscottdurow
Αποθετήριοpower-platform-full-stack-skills
Όνομα δεξιότηταςvite-react
Αστέρια
39
Forks
10
Συνοδευτικά αρχεία
Μόνο οδηγίες
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • Αυτοτελής

    Όλα όσα χρειάζεται το μοντέλο περιλαμβάνονται στις οδηγίες — χωρίς επιπλέον αρχεία για συγχρονισμό.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε από scottdurow στο GitHub. Διαβάστε το πηγαίο περιεχόμενο πριν εγκαταστήσετε τη δεξιότητα.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Vite React στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/scottdurow/power-platform-full-stack-skills/tree/main/skills/vite-react
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Νέα δεξιότητα → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που διαβάζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/scottdurow/power-platform-full-stack-skills.git /tmp/power-platform-full-stack-skills
mkdir -p .claude/skills
cp -r /tmp/power-platform-full-stack-skills/skills/vite-react .claude/skills/vite-react
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Vite React σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Vite React μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Vite React δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλα κατά τη συνομιλία

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου SKILL.md που φορτώνει το μοντέλο. Διαβάστε το πριν από την εγκατάσταση — μια δεξιότητα αποτελείται από οδηγίες που θα ακολουθήσει το μοντέλο σας.

Vite + React + TypeScript Best Practices

You are an expert in building modern web applications with Vite, React, and TypeScript. These patterns apply to any Vite+React project — whether standalone, embedded in Power Platform, or deployed elsewhere.

Project Scaffolding with create-vite

Always use the official create-vite scaffolder to initialize new projects. Do NOT manually create project files (package.json, tsconfig, vite.config.ts, etc.) — use the scaffolder to get the latest official template.

Interactive CLI Requirement

create-vite v6+ uses interactive prompts (@clack/prompts) that require arrow-key navigation and cannot be driven by non-interactive terminals. The run_in_terminal tool with isBackground: false cannot send keypresses to these menus, so the command will hang and exit silently with code 1.

Solution: Launch as a background terminal and let the user interact.

  1. Clean the target directory (if needed) using run_in_terminal with isBackground: false:

    powershell
    # Remove existing scaffold files if re-scaffolding
    Remove-Item -Force eslint.config.js, index.html, package.json, ... -ErrorAction SilentlyContinue
  2. Launch create-vite in a background terminal so the user can interact with the prompts:

    run_in_terminal:
      command: npm create vite@latest . -- --template react-ts
      isBackground: true
  3. Tell the user to switch to the terminal pane and complete the interactive steps (select framework, variant, package name, etc.).

  4. After the user confirms completion, verify the scaffold by listing files:

    powershell
    Get-ChildItem -Force | Select-Object Name
  5. Run npm install (non-background):

    powershell
    npm install
  6. Verify the build:

    powershell
    npm run build

Key Rules

  • Never skip the scaffolder — it produces the latest recommended config (tsconfig, eslint, vite.config) which evolves across Vite versions
  • Never use isBackground: false for create-vite — it will hang on the interactive prompts
  • Never pin to older create-vite versions (e.g., npm create vite@5) just to avoid prompts — always use @latest
  • Always verify with npm run build after scaffolding to confirm the template is working

Feature-First Project Structure

Organize code by feature, not by file type. Each feature owns its models, services, hooks, and components:

src/
├── features/
│   ├── accounts/
│   │   ├── models/
│   │   │   └── Account.ts          # Domain model types and DTOs
│   │   ├── services/
│   │   │   └── AccountService.ts    # Service layer wrapping API calls
│   │   ├── hooks/
│   │   │   └── useAccounts.ts       # React Query hooks
│   │   └── components/
│   │       ├── AccountList.tsx       # List view
│   │       ├── AccountDetail.tsx     # Detail view
│   │       └── AccountForm.tsx       # Create/edit form
│   ├── contacts/
│   │   ├── models/
│   │   ├── services/
│   │   ├── hooks/
│   │   └── components/
│   └── shared/
│       └── components/              # Cross-feature UI components
├── App.tsx
└── main.tsx

Why feature-first?

  • Collocated code is easier to navigate and maintain
  • Features can be moved, renamed, or deleted as a unit
  • Avoids giant components/, hooks/, services/ folders
  • Clear ownership boundaries between features

Terminal Working Directory Discipline

When working in a multi-project workspace (e.g., code-app/ and power-pages/ as siblings), ALWAYS use absolute or explicit relative paths at the start of terminal commands:

powershell
# GOOD — explicit directory
Set-Location c:\src\MyWorkspace\code-app; npm run build

# BAD — assumes current directory
npm run build

Rules:

  • At the start of every terminal command, set the working directory explicitly
  • Never assume the terminal is "still" in the directory from the last command
  • If a command fails with "file not found", check the current directory first

Dev Server Lifecycle Management

Before starting a dev server (npm run dev, vite, etc.):

  1. Kill any existing instances:

    powershell
    Get-Process -Name "node" -ErrorAction SilentlyContinue |
      Where-Object { $_.CommandLine -match 'vite' } |
      Stop-Process -Force
  2. Use --strictPort to prevent port cascading:

    typescript
    // vite.config.ts
    export default defineConfig({
      server: {
        port: 5173,
        strictPort: true, // FAIL instead of silently picking next port
      },
    });
  3. After browser testing, kill the dev server explicitly. Don't leave zombie processes.


Service Layer, React Query & Error Handling

Use the ioc-development-pattern skill for the complete service layer pattern — service interfaces, domain models with DTOs (CreateDto/UpdateDto), in-memory implementations for local development, service registry, React Query (TanStack Query) integration with query key factories, cache invalidation, mutation hooks, optimistic updates, real backend service implementations with error handling, and incremental backend migration. That skill is the single source of truth for data access patterns.


State Management Strategy

Most state in a data-driven business app is server state (fetched data). Use this hierarchy:

Server State → React Query (TanStack Query)

Managed by the ioc-development-pattern skill. React Query handles:

  • Fetching, caching, and synchronizing server data
  • Background refetching and cache invalidation
  • Loading/error/success states
  • Optimistic updates for mutations

This covers 80-90% of state in a typical business app.

UI State → React Context + useState

For cross-component UI state that doesn't come from the server:

State TypeApproachExample
Component-localuseStateForm inputs, open/close toggles, selected tab
Feature-scopeduseState lifted to parentSelected list item, filter state
App-wide UIReact ContextTheme preference, sidebar collapsed, current user display
URL stateURL search paramsActive filters, selected tab, page number
tsx
// src/contexts/UIContext.tsx — minimal app-wide UI state
import { createContext, useContext, useState, type ReactNode } from "react";

interface UIState {
  sidebarCollapsed: boolean;
  toggleSidebar: () => void;
}

const UIContext = createContext<UIState | null>(null);

export function UIProvider({ children }: { children: ReactNode }) {
  const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
  return (
    <UIContext.Provider value={{
      sidebarCollapsed,
      toggleSidebar: () => setSidebarCollapsed(prev => !prev),
    }}>
      {children}
    </UIContext.Provider>
  );
}

export function useUI() {
  const ctx = useContext(UIContext);
  if (!ctx) throw new Error("useUI must be within UIProvider");
  return ctx;
}

What NOT to Do

  • Don't use Redux/Zustand for server state — React Query does this better with caching, invalidation, and background sync
  • Don't put form state in global stores — Keep it in the form component with useState
  • Don't duplicate server data in local state — Use React Query's cache as the source of truth
  • Don't create a context for every feature — Only lift state up when multiple unrelated components need it
  • Exception: Zustand IS appropriate for cross-cutting UI concerns like the notification queue (see ui-fluentui-react skill → Mandatory Shell Scaffold). The notification store bridges service/hook layer → React toast UI, which React Context alone cannot do cleanly.

Decision Guide

Is this data from the server? → React Query (via ioc-development-pattern hooks)
Is this component-local? → useState
Do siblings need to share it? → Lift state to parent
Do unrelated components need it? → React Context
Does it belong in the URL? → URL search params (useSearchParams)
Is it a cross-cutting notification queue? → Zustand (see notification store pattern)

Fluent UI v9 Component Patterns

Use the ui-fluentui-react skill for all Fluent UI v9 guidance — component patterns (list views, detail views, forms, dialogs, drawers, data grids, toasts), makeStyles styling with design tokens, FluentProvider setup, theming, layout patterns, toolbar/navigation, and the business component checklist (loading/error/empty/disabled states). That skill is the single source of truth for Fluent UI React v9.


NON-NEGOTIABLE: Routing — Catch-All 404 Route

Every React Router app must include a catch-all route that shows a "Not Found" screen. Never redirect unknown paths to / silently — this masks broken links and confuses users.

The route tree MUST be wrapped in <ErrorBoundary> and <Suspense>:

tsx
// App.tsx — route configuration
import { Suspense } from "react";
import { Routes, Route } from "react-router-dom";
import { Spinner } from "@fluentui/react-components";
import { ErrorBoundary } from "./shared/components/ErrorBoundary";
import { NotificationBridge } from "./shared/components/NotificationBridge";

export default function App() {
  return (
    <ErrorBoundary>
      <NotificationBridge />
      <Suspense fallback={<div style={{ display: "flex", justifyContent: "center", padding: "48px" }}><Spinner label="Loading..." size="medium" /></div>}>
        <Routes>
          <Route path="/" element={<AppShell />}>
            <Route index element={<DashboardScreen />} />
            <Route path="projects" element={<ProjectListScreen />} />
            <Route path="projects/new" element={<ProjectNewScreen />} />
            <Route path="projects/:id" element={<ProjectDetailScreen />} />
            {/* ... other routes ... */}

            {/* ✅ Catch-all — shows 404 page */}
            <Route path="*" element={<NotFoundScreen />} />
          </Route>
        </Routes>
      </Suspense>
    </ErrorBoundary>
  );
}

ErrorBoundary and Suspense are mandatory. Without ErrorBoundary, a single component crash takes down the entire app. Without Suspense, any React.lazy() import or suspense-enabled data fetch crashes the app with an unhandled promise. See ui-fluentui-react skill → "Mandatory Shell Scaffold" for the full required structure.

tsx
// screens/NotFoundScreen.tsx — minimal implementation
import { Button, Text, tokens, makeStyles } from "@fluentui/react-components";
import { useNavigate } from "react-router-dom";

const useStyles = makeStyles({
  root: {
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "center",
    height: "100%",
    gap: tokens.spacingVerticalL,
    padding: tokens.spacingHorizontalXXL,
  },
});

export function NotFoundScreen() {
  const navigate = useNavigate();
  const styles = useStyles();
  return (
    <div className={styles.root}>
      <Text size={800} weight="bold">404</Text>
      <Text size={400}>Page not found</Text>
      <Button appearance="primary" onClick={() => navigate("/")}>
        Go to Dashboard
      </Button>
    </div>
  );
}

Rules:

  • <Route path="*"> must be the last child inside the layout route
  • Never use <Navigate to="/" replace /> as a catch-all — this silently hides broken routes
  • The 404 screen should offer navigation back to the dashboard or home

Build & Lint Validation Workflow

Run these checks after every significant code change and ALWAYS before deployment:

Step 1: TypeScript Compilation

bash
npm run build
  • Must exit with code 0
  • Check for: type mismatches, missing imports, undefined properties, generic type errors

Step 2: ESLint Check

bash
npm run lint
  • Must exit with code 0
  • Check for: unused variables, missing useEffect dependencies, incorrect hook usage

Step 3: Auto-Fix (if issues found)

bash
npm run lint -- --fix

Auto-fixable: import sorting, semicolons, whitespace, unused imports, quote style. Non-fixable (manual): logic errors, type errors, complex rule violations.

Recommended package.json Scripts

json
{
  "scripts": {
    "dev": "vite",
    "build": "tsc -b && vite build",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  }
}

Vite Configuration Best Practices

Base Path for Embedded/Hosted Deployments

When deploying to a non-root path (e.g., Power Platform, SharePoint, subdirectory hosting):

typescript
export default defineConfig({
  plugins: [react()],
  base: './',  // Relative paths — assets resolve correctly in any hosting location
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    rollupOptions: {
      output: {
        manualChunks: {
          'vendor-react': ['react', 'react-dom', 'react-router-dom'],
          'vendor-fluent': ['@fluentui/react-components', '@fluentui/react-icons'],
          'vendor-query': ['@tanstack/react-query'],
        },
      },
    },
  },
});

Manual chunk splitting is required. Without it, the entire app bundles into a single large JS file. Splitting React, Fluent UI, and React Query into separate vendor chunks enables browser caching — vendor chunks rarely change, so users only re-download app code on updates. This can reduce reload times by 60-80% after the first visit.

Without base: './', built HTML references assets with absolute paths (/assets/index.js) which break when deployed to a non-root URL.

Verify After Build

bash
cat dist/index.html | grep -E 'src=|href='
# ✅ Good: src="./assets/index-abc123.js"
# ❌ Bad:  src="/assets/index-abc123.js"

Single-File Build for Embedding

When you need the entire app in a single HTML file (e.g., for web resources or iframes):

bash
npm install -D vite-plugin-singlefile
typescript
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteSingleFile } from "vite-plugin-singlefile";

export default defineConfig({
  plugins: [react(), viteSingleFile()],
  build: {
    assetsInlineLimit: 100000000,
    cssCodeSplit: false,
  },
});

Produces a single dist/index.html with all JS/CSS inlined.

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Vite React;

Best practices for Vite + React + TypeScript web applications. Covers feature-first project structure, build/lint validation workflows, Vite configuration, and single-file build for embedding. For service layer patterns, domain models/DTOs, React Query integration, and error handling, see the `ioc-development-pattern` skill. For Fluent UI v9 component patterns, styling, and theming, see the `ui-fluentui-react` skill. Triggers on "vite", "react app", "feature structure", "vite build", "react typescript", "single file build", "vite config".

Γιατί να χρησιμοποιήσετε τη δεξιότητα Vite React στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Vite React είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη Vite React στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε το https://github.com/scottdurow/power-platform-full-stack-skills/tree/main/skills/vite-react. Το TypingMind διαβάζει το αρχείο SKILL.md και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Vite React;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη Vite React;

Με όσα θέλετε. Εφόσον ένα μοντέλο υποστηρίζει δεξιότητες, μπορείτε να χρησιμοποιήσετε τη Vite React με αυτό — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama και άλλα — όλα στο TypingMind με τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Vite React;

Δημοσιεύεται στο GitHub από τον χρήστη scottdurow. Ελέγξτε το αποθετήριο για τους όρους αδειοδότησης. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇