dify/web
2026-04-11 12:10:30 +00:00
..
__mocks__ refactor(web): migrate notion page selectors to tanstack virtual (#34508) 2026-04-03 07:03:12 +00:00
__tests__ test: add unit tests for AppPublisher, Sidebar, Chat, FileUploader, Form Demo, Notion Page Selector, Prompt Editor, and Header Navigation components (#34802) 2026-04-09 07:30:51 +00:00
.storybook refactor(web): migrate remaining toast usage (#34433) 2026-04-02 04:16:50 +00:00
.vscode
app refactor: remove base ui i18n dependency (#34921) 2026-04-11 12:10:30 +00:00
assets
bin
config feat(web): add ALLOW_INLINE_STYLES env var to opt-in inline CSS in Markdown rendering (#34719) 2026-04-08 08:38:24 +00:00
constants
context chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
contract chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
docker feat(web): add ALLOW_INLINE_STYLES env var to opt-in inline CSS in Markdown rendering (#34719) 2026-04-08 08:38:24 +00:00
docs fix: simplify pre-commit hook flow (#34637) 2026-04-07 04:19:31 +00:00
hooks fix: copy button not working on API Server and API Key pages (#34515) 2026-04-09 02:49:40 +00:00
i18n refactor: remove base ui i18n dependency (#34921) 2026-04-11 12:10:30 +00:00
i18n-config chore: update deps (#34487) 2026-04-03 03:26:49 +00:00
models chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
next refactor: use ungh for github api (#34108) 2026-03-26 14:37:17 +08:00
plugins chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
public chore: revert #33540 #32966 (#33566) 2026-03-17 12:55:58 +08:00
scripts chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
service test: add unit tests for AppPublisher, Sidebar, Chat, FileUploader, Form Demo, Notion Page Selector, Prompt Editor, and Header Navigation components (#34802) 2026-04-09 07:30:51 +00:00
test chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
themes
types chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
utils chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
.env.example feat(web): add ALLOW_INLINE_STYLES env var to opt-in inline CSS in Markdown rendering (#34719) 2026-04-08 08:38:24 +00:00
.gitignore
.npmrc
AGENTS.md
CLAUDE.md
Dockerfile build: include vinext in docker build (#34535) 2026-04-08 07:26:39 +00:00
Dockerfile.dockerignore build: include packages in docker build (#34532) 2026-04-03 13:40:16 +00:00
env.ts feat(web): add ALLOW_INLINE_STYLES env var to opt-in inline CSS in Markdown rendering (#34719) 2026-04-08 08:38:24 +00:00
eslint-suppressions.json test: add unit tests for workflow components including tools and inspect vars (#34843) 2026-04-10 13:11:36 +00:00
eslint.config.mjs refactor(web): move avatar to base ui (#34889) 2026-04-10 04:44:05 +00:00
eslint.constants.mjs refactor(web): migrate remaining toast usage (#34433) 2026-04-02 04:16:50 +00:00
global.d.ts
instrumentation-client.ts refactor: prefer instrumentation-client (#34009) 2026-03-25 09:54:25 +08:00
knip.config.ts chore: knip fix (#34481) 2026-04-02 15:03:42 +00:00
next.config.ts refactor: introduce pnpm workspace (#34241) 2026-03-30 10:34:50 +00:00
package.json fix: copy button not working on API Server and API Key pages (#34515) 2026-04-09 02:49:40 +00:00
postcss.config.js refactor: update to tailwind v4 (#34415) 2026-04-02 07:06:11 +00:00
proxy.ts refactor: use ungh for github api (#34108) 2026-03-26 14:37:17 +08:00
README.md refactor: introduce pnpm workspace (#34241) 2026-03-30 10:34:50 +00:00
tailwind-common-config.ts refactor: split icon collections (#34453) 2026-04-02 07:58:15 +00:00
tailwind.config.ts chore: update deps (#33862) 2026-03-23 10:54:01 +08:00
tsconfig.json
tsslint.config.ts
typography.js refactor: update to tailwind v4 (#34415) 2026-04-02 07:06:11 +00:00
vite.config.ts refactor: update to tailwind v4 (#34415) 2026-04-02 07:06:11 +00:00
vitest.setup.ts fix: copy button not working on API Server and API Key pages (#34515) 2026-04-09 02:49:40 +00:00

Dify Frontend

This is a Next.js project, but you can dev with vinext.

Getting Started

Run by source code

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

You can also use Vite+ with the corresponding vp commands. For example, use vp install instead of pnpm install and vp test instead of pnpm run test.

Tip

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

npm install -g corepack
corepack enable

Learn more: Corepack

Run the following commands from the repository root.

First, install the dependencies:

pnpm install

Note

JavaScript dependencies are managed by the workspace files at the repository root: package.json, pnpm-lock.yaml, pnpm-workspace.yaml, and .nvmrc. Install dependencies from the repository root, then run frontend scripts from web/.

Then, configure the environment variables. Create web/.env.local and copy the contents from web/.env.example. Modify the values of these environment variables according to your requirements:

cp web/.env.example web/.env.local

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 -C web run dev
# or if you are using vinext which provides a better development experience
pnpm -C web run dev:vinext
# (optional) start the dev proxy server so that you can use online API in development
pnpm -C web run dev:proxy

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

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

Deploy

Deploy on server

First, build the app for production:

pnpm -C web run build

Then, start the server:

pnpm -C web run start

If you build the Docker image manually, use the repository root as the build context:

docker build -f web/Dockerfile -t dify-web .

If you want to customize the host and port:

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

Storybook

This project uses Storybook for UI component development.

To start the storybook server, run:

pnpm -C web 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/docs/test.md for detailed testing specifications, best practices, and examples.

Important

As we are using Vite+, the vitest command is not available. Please make sure to run tests with vp commands. For example, use npx vp test instead of npx vitest.

Run test:

pnpm -C web test

Note

Our test is not fully stable yet, and we are actively working on improving it. If you encounter test failures only in CI but not locally, please feel free to ignore them and report the issue to us. You can try to re-run the test in CI, and it may pass successfully.

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.