dify/web
Li zhongyu 7507e9ba67
refactor(web): migrate debug-and-preview-panel-width to useSetLocalStorage (#36977)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-06-03 03:27:15 +00:00
..
__mocks__ fix(dify-ui): align form label guidance (#36510) 2026-05-22 07:29:57 +00:00
__tests__ refactor(web): migrate education verifying storage to useLocalStorage (#36934) 2026-06-03 02:16:59 +00:00
.storybook refactor: verticalize tag management and batch bindings (#35840) 2026-05-07 01:36:10 +00:00
.vscode chore: workspace lint (#35331) 2026-04-16 16:47:53 +00:00
app refactor(web): migrate debug-and-preview-panel-width to useSetLocalStorage (#36977) 2026-06-03 03:27:15 +00: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 feat(web): create system-features vertical (#36894) 2026-06-01 10:15:25 +00:00
constants fix: check and update doc links (#30849) 2026-01-21 16:31:48 +08:00
context refactor(web): migrate education verifying storage to useLocalStorage (#36934) 2026-06-03 02:16:59 +00:00
contract fix(web): use generated account-profile contracts (#36927) 2026-06-02 07:28:05 +00:00
docker chore: not request system-features for cloud edition (#36891) 2026-06-01 09:31:16 +00:00
docs feat(ui): migrate radio to Base UI and update web callsites (#36451) 2026-05-20 12:05:31 +00:00
features fix(web): use generated account-profile contracts (#36927) 2026-06-02 07:28:05 +00:00
hooks refactor(web): migrate NEED_REFRESH_APP_LIST_KEY to useLocalStorage/useSetLocalStorage (#36908) 2026-06-02 08:41:01 +00:00
i18n feat: per-credential visibility control for plugin credentials (#35468) 2026-06-01 05:56:18 +00:00
i18n-config chore: workspace level typecheck (#35329) 2026-04-16 14:42:04 +00:00
models fix(web): use generated account-profile contracts (#36927) 2026-06-02 07:28:05 +00:00
next feat: marketplace and oauth fixes (#35509) 2026-04-24 07:53:14 +00:00
plugins feat(dev-proxy): init package (#35852) 2026-05-07 03:32:14 +00:00
public chore: fix oxlint warnings (unused variables and imports) (#35249) 2026-04-20 13:43:17 +00:00
scripts fix(web): read pnpm config env in standalone start (#36887) 2026-06-01 07:18:50 +00:00
service fix(web): use generated account-profile contracts (#36927) 2026-06-02 07:28:05 +00:00
test fix(web): use generated account-profile contracts (#36927) 2026-06-02 07:28:05 +00:00
themes chore(tailwind-css): migrate to css first (#35754) 2026-05-06 04:28:11 +00:00
types feat(web): create system-features vertical (#36894) 2026-06-01 10:15:25 +00:00
utils refactor(web): migrate local storage access to react hook (#36888) 2026-06-01 07:57:54 +00:00
.env.example chore: not request system-features for cloud edition (#36891) 2026-06-01 09:31:16 +00:00
.gitignore chore: ignore .vinext (#36914) 2026-06-02 02:43:15 +00:00
AGENTS.md docs: add client state guidelines (#36900) 2026-06-01 11:44:50 +00:00
CLAUDE.md test: add comprehensive tests for CustomizeModal component (#29709) 2025-12-16 14:21:05 +08:00
dev-proxy.config.ts feat(dev-proxy): isolate local auth cookies by target (#36371) 2026-05-19 05:59:55 +00:00
Dockerfile fix(docker): pin web docker node version (#36756) 2026-05-28 05:25:41 +00:00
Dockerfile.dockerignore build: include packages in docker build (#34532) 2026-04-03 13:40:16 +00:00
env.ts chore: not request system-features for cloud edition (#36891) 2026-06-01 09:31:16 +00:00
eslint.config.mjs refactor(web): migrate local storage hook usage (#36890) 2026-06-01 08:20:13 +00:00
eslint.constants.mjs chore(web): restrict legacy service fetch imports (#36701) 2026-05-27 03:08:35 +00:00
global.d.ts chore: upgrade dependencies (#36606) 2026-05-25 05:42:35 +00:00
instrumentation-client.ts chore: workspace level typecheck (#35329) 2026-04-16 14:42:04 +00:00
knip.config.ts feat(dev-proxy): init package (#35852) 2026-05-07 03:32:14 +00:00
next.config.ts feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
package.json chore(web): remove TanStack devtools (#36882) 2026-06-01 03:57:50 +00:00
postcss.config.js refactor: update to tailwind v4 (#34415) 2026-04-02 07:06:11 +00:00
proxy.ts refactor(web): remove app initializer and move auth boot logic to route boundaries (#36818) 2026-05-29 12:26:34 +00:00
README.md feat(ui): migrate radio to Base UI and update web callsites (#36451) 2026-05-20 12:05:31 +00:00
tsconfig.json chore: generate enterprise console API (#35735) 2026-04-30 09:15:08 +00:00
tsslint.config.ts fix: enforce no-leaked-conditional-rendering as error and fix violations (#31262) 2026-01-20 23:08:59 +08:00
vite.config.ts refactor(web): portal to follow elem migration (#35892) 2026-05-07 13:02:11 +00:00
vitest.setup.ts refactor(web): drop headless-ui, migrate overlay to dify-ui (#35963) 2026-05-09 10:33:25 +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
# edit web/dev-proxy.config.ts to choose proxy paths
# edit web/.env.local to override DEV_PROXY_TARGET, DEV_PROXY_ENTERPRISE_TARGET, DEV_PROXY_HOST, or DEV_PROXY_PORT
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 .vscode/settings.example.json to .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.