dify/web
zhsama 4d82769baa fix: Fix null safety issues in workflow variable components 2026-01-31 21:26:32 +08:00
..
.husky
.storybook chore: update to story book nextjs-vite (#31536) 2026-01-26 17:07:20 +08:00
.vscode chore: init tsslint (#31209) 2026-01-20 11:08:50 +08:00
__mocks__ revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
__tests__
app fix: Fix null safety issues in workflow variable components 2026-01-31 21:26:32 +08:00
assets
bin
config refactor: Refactor storage keys into hierarchical structure 2026-01-30 23:23:21 +08:00
constants fix: check and update doc links (#30849) 2026-01-22 16:13:09 +08:00
context refactor: type event emitter payloads 2026-01-31 00:04:57 +08:00
contract feat(sandbox): refactor sandbox file handling to include app_id 2026-01-30 22:45:28 +08:00
docker
docs docs: relocate frontend docs for agents and human (#31714) 2026-01-29 17:58:10 +08:00
eslint-rules chore: Revert "refactor: prefer css icon" (#31733) 2026-01-30 12:26:07 +08:00
hooks refactor: Refactor context generate modal storage key management 2026-01-30 22:59:53 +08:00
i18n feat: add ZIP skill import with client-side extraction 2026-01-30 21:54:00 +08:00
i18n-config fix: check and update doc links (#30849) 2026-01-22 16:13:09 +08:00
models revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
public
scripts Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-30 20:08:35 +08:00
service feat(sandbox): refactor sandbox file handling to include app_id 2026-01-30 22:45:28 +08:00
test
themes revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
types feat(sandbox): refactor sandbox file handling to include app_id 2026-01-30 22:45:28 +08:00
utils Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-29 21:25:28 +08:00
.dockerignore
.env.example env var NEXT_PUBLIC_SOCKET_URL 2026-01-20 20:34:56 +08:00
.gitignore
.npmrc chore(web): remove version prefixes from package.json (#31286) 2026-01-20 21:14:50 +08:00
.nvmrc
AGENTS.md docs: relocate frontend docs for agents and human (#31714) 2026-01-29 17:58:10 +08:00
CLAUDE.md
Dockerfile feat: Add sourcemap build arg for web dev deployments 2026-01-29 15:43:56 +08:00
README.md Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-29 21:25:28 +08:00
eslint-suppressions.json chore: prune eslint suppressions 2026-01-31 00:31:57 +08:00
eslint.config.mjs Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-30 20:08:35 +08:00
global.d.ts
knip.config.ts
next.config.ts feat: Add sourcemap build arg for web dev deployments 2026-01-29 15:43:56 +08:00
package.json feat: add ZIP skill import with client-side extraction 2026-01-30 21:54:00 +08:00
pnpm-lock.yaml feat: add ZIP skill import with client-side extraction 2026-01-30 21:54:00 +08:00
postcss.config.js
proxy.ts Merge remote-tracking branch 'myori/main' into feat/collaboration2 2026-01-24 15:22:07 +08:00
tailwind-common-config.ts Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-30 20:08:35 +08:00
tailwind.config.js build: bump NextJS from to 16 with turbopack enable for web production build boost (#27014) 2026-01-21 12:53:29 +08:00
tsconfig.json Merge remote-tracking branch 'myori/main' into feat/collaboration2 2026-01-24 15:22:07 +08:00
tsslint.config.ts fix: enforce no-leaked-conditional-rendering as error and fix violations (#31262) 2026-01-20 23:08:59 +08:00
typography.js
vite.config.ts chore: follow-up fixes for storybook vite migration (#31545) 2026-01-26 20:20:14 +08:00
vitest.config.ts chore: follow-up fixes for storybook vite migration (#31545) 2026-01-26 20:20:14 +08:00
vitest.setup.ts Merge remote-tracking branch 'origin/main' into feat/support-agent-sandbox 2026-01-27 16:22:02 +08:00

README.md

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=
# WebSocket server URL.
NEXT_PUBLIC_SOCKET_URL=ws://localhost:5001
# 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.

Then follow the Lint Documentation to lint the code.

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 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.