dify/web
Coding On Star 8f43629cd8
fix(amplitude): update sessionReplaySampleRate default value to 0.5 (#30880)
Co-authored-by: CodingOnStar <hanxujiang@dify.ai>
2026-01-13 12:26:50 +08:00
..
__mocks__ feat(web): migrate from es-toolkit/compat to native es-toolkit (#30244) (#30246) 2025-12-31 11:13:22 +08:00
__tests__ refactor(web): remove useMixedTranslation, better resource loading (#30630) 2026-01-07 13:20:09 +08:00
.husky chore: update TypeScript type-check command and add native-preview dependency for faster performance (#29179) 2025-12-05 14:42:37 +08:00
.storybook fix: Broken import in .storybook/preview.tsx (#30812) 2026-01-10 19:49:23 +08:00
.vscode chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
app fix(amplitude): update sessionReplaySampleRate default value to 0.5 (#30880) 2026-01-13 12:26:50 +08:00
assets feat: introduce trigger functionality (#27644) 2025-11-12 17:59:37 +08:00
bin refactor(web): migrate to Vitest and esm (#29974) 2025-12-22 16:35:22 +08:00
config refactor(i18n): use JSON with flattened key and namespace (#30114) 2025-12-29 14:52:32 +08:00
context refactor(web): extract isServer/isClient utility & upgrade Node.js to 22.12.0 (#30803) 2026-01-12 12:57:43 +08:00
docker fix: Login secret text transmission (#29659) 2025-12-16 16:55:51 +08:00
eslint-rules chore(web): add ESLint rules for i18n JSON validation (#30491) 2026-01-05 15:49:31 +08:00
hooks refactor(web): extract isServer/isClient utility & upgrade Node.js to 22.12.0 (#30803) 2026-01-12 12:57:43 +08:00
i18n chore(i18n): sync translations with en-US (#30750) 2026-01-08 22:53:04 +08:00
i18n-config feat(i18n): Migrate translation workflow to Claude Code GitHub Actions (#30692) 2026-01-07 21:17:50 +08:00
models feat: enhance start node object value check (#30732) 2026-01-09 16:13:17 +08:00
public feat(web): migrate PWA to Serwist (#30808) 2026-01-10 17:16:18 +09:00
scripts feat(i18n): Migrate translation workflow to Claude Code GitHub Actions (#30692) 2026-01-07 21:17:50 +08:00
service fix: fix refresh token deadlock (#30828) 2026-01-12 09:35:31 +08:00
test test: unify i18next mocks into centralized helpers (#30376) 2025-12-31 16:53:33 +09:00
testing test: unify i18next mocks into centralized helpers (#30376) 2025-12-31 16:53:33 +09:00
themes fix(theme): make sticky headers opaque in dark mode (Monaco sticky sc… (#29826) 2025-12-18 15:00:15 +08:00
types refactor(web): remove useMixedTranslation, better resource loading (#30630) 2026-01-07 13:20:09 +08:00
utils fix: fix formatNumber accuracy (#30877) 2026-01-13 11:51:15 +08:00
.dockerignore chore: update dockerignore (#30460) 2026-01-05 10:55:14 +08:00
.env.example fix: entrypoint.sh overrides NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS when TEXT_GENERATION_TIMEOUT_MS is unset (#30864) (#30865) 2026-01-13 10:12:51 +08:00
.gitignore chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
.nvmrc refactor(web): extract isServer/isClient utility & upgrade Node.js to 22.12.0 (#30803) 2026-01-12 12:57:43 +08:00
AGENTS.md test: add comprehensive tests for CustomizeModal component (#29709) 2025-12-16 14:21:05 +08:00
CLAUDE.md test: add comprehensive tests for CustomizeModal component (#29709) 2025-12-16 14:21:05 +08:00
Dockerfile build: limit esbuild, glob, docker base version to avoid cve (#30848) 2026-01-12 15:33:20 +08:00
eslint.config.mjs feat: init rsc support for translation (#30596) 2026-01-06 13:23:03 +08:00
global.d.ts feat: integrate Google Analytics event tracking and update CSP for script sources (#30365) 2025-12-30 18:06:47 +08:00
knip.config.ts feat(web): migrate PWA to Serwist (#30808) 2026-01-10 17:16:18 +09:00
middleware.ts integrate Amplitude analytics into the application (#29049) 2025-12-03 14:22:12 +08:00
next.config.js feat(web): migrate PWA to Serwist (#30808) 2026-01-10 17:16:18 +09:00
package.json build: limit esbuild, glob, docker base version to avoid cve (#30848) 2026-01-12 15:33:20 +08:00
pnpm-lock.yaml build: limit esbuild, glob, docker base version to avoid cve (#30848) 2026-01-12 15:33:20 +08:00
postcss.config.js refactor(web): migrate to Vitest and esm (#29974) 2025-12-22 16:35:22 +08:00
README.md docs(web): add corepack recommendation (#30837) 2026-01-12 12:44:30 +08:00
tailwind-common-config.ts refactor(web): migrate to Vitest and esm (#29974) 2025-12-22 16:35:22 +08:00
tailwind.config.js chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
tsconfig.json chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
typography.js refactor(web): migrate to Vitest and esm (#29974) 2025-12-22 16:35:22 +08:00
vitest.config.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
vitest.setup.ts test: unify i18next mocks into centralized helpers (#30376) 2025-12-31 16:53:33 +09:00

Dify Frontend

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Run by source code

Before starting the web frontend service, please make sure the following environment is ready.

Tip

It is recommended to install and enable Corepack to manage package manager versions automatically:

npm install -g corepack
corepack enable

Learn more: Corepack

First, install the dependencies:

pnpm install

Then, configure the environment variables. Create a file named .env.local in the current directory and copy the contents from .env.example. Modify the values of these environment variables according to your requirements:

cp .env.example .env.local
# For production release, change this to PRODUCTION
NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT
# The deployment edition, SELF_HOSTED
NEXT_PUBLIC_EDITION=SELF_HOSTED
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai/console/api
NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/api
NEXT_PUBLIC_COOKIE_DOMAIN=
# The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app/api
NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api

# SENTRY
NEXT_PUBLIC_SENTRY_DSN=

Important

  1. When the frontend and backend run on different subdomains, set NEXT_PUBLIC_COOKIE_DOMAIN=1. The frontend and backend must be under the same top-level domain in order to share authentication cookies.
  2. It's necessary to set NEXT_PUBLIC_API_PREFIX and NEXT_PUBLIC_PUBLIC_API_PREFIX to the correct backend API URL.

Finally, run the development server:

pnpm run dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the file under folder app. The page auto-updates as you edit the file.

Deploy

Deploy on server

First, build the app for production:

pnpm run build

Then, start the server:

pnpm run start

If you want to customize the host and port:

pnpm run start --port=3001 --host=0.0.0.0

If you want to customize the number of instances launched by PM2, you can configure PM2_INSTANCES in docker-compose.yaml or Dockerfile.

Storybook

This project uses Storybook for UI component development.

To start the storybook server, run:

pnpm storybook

Open http://localhost:6006 with your browser to see the result.

Lint Code

If your IDE is VSCode, rename web/.vscode/settings.example.json to web/.vscode/settings.json for lint code setting.

Test

We use Vitest and React Testing Library for Unit Testing.

📖 Complete Testing Guide: See web/testing/testing.md for detailed testing specifications, best practices, and examples.

Run test:

pnpm test

Example Code

If you are not familiar with writing tests, refer to:

Analyze Component Complexity

Before writing tests, use the script to analyze component complexity:

pnpm analyze-component app/components/your-component/index.tsx

This will help you determine the testing strategy. See web/testing/testing.md for details.

Documentation

Visit https://docs.dify.ai/getting-started/readme to view the full documentation.

Community

The Dify community can be found on Discord community, where you can ask questions, voice ideas, and share your projects.