Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify UseShare

From Leeroopedia


Knowledge Sources
Domains Frontend, Web App, Shared Conversations
Last Updated 2026-02-08 00:00 GMT

Overview

React Query hooks for the Dify web-app (shared application) interface, providing access mode checks, app info/params/meta queries, conversation lists, chat history, and conversation name generation.

Description

The UseShare module provides TanStack React Query hooks for the Dify web-app and shared application pages. These hooks power the end-user-facing chat and completion interfaces. The module includes:

  • shareQueryKeys -- A centralized query key factory for consistent cache management across all share-related queries.
  • useGetWebAppAccessModeByCode -- Checks the access mode for a shared app by its share code.
  • useGetWebAppInfo / useGetWebAppParams / useGetWebAppMeta -- Fetch app information, parameters, and metadata for the current web app.
  • useShareConversations -- Fetches paginated conversation lists with support for different app source types (webApp, installedApp, tryApp), pinned filtering, and configurable refetch behavior.
  • useShareChatList -- Retrieves the message list for a specific conversation, with staleTime: 0 to ensure fresh data when switching conversations.
  • useShareConversationName -- Generates or retrieves the name of a conversation.
  • useInvalidateShareConversations -- Invalidates the conversation list cache.

All hooks respect AppSourceType constraints, disabling queries for try-app mode and requiring app IDs for installed-app mode.

Usage

Use these hooks in the shared web-app pages (/chat, /completion, /workflow) and in installed app views within the Dify Explore section to display conversations, chat histories, and app metadata.

Code Reference

Source Location

Signature

export const shareQueryKeys: {
  appAccessMode: (code: string | null) => readonly [...]
  appInfo: readonly [...]
  appParams: readonly [...]
  appMeta: readonly [...]
  conversations: readonly [...]
  conversationList: (params: ShareConversationsParams) => readonly [...]
  chatList: (params: ShareChatListParams) => readonly [...]
  conversationName: (params: ShareConversationNameParams) => readonly [...]
}

export const useGetWebAppAccessModeByCode: (code: string | null) => UseQueryResult
export const useGetWebAppInfo: () => UseQueryResult
export const useGetWebAppParams: () => UseQueryResult
export const useGetWebAppMeta: () => UseQueryResult
export const useShareConversations: (params: ShareConversationsParams, options?: ShareQueryOptions) => UseQueryResult<AppConversationData>
export const useShareChatList: (params: ShareChatListParams, options?: ShareQueryOptions) => UseQueryResult
export const useShareConversationName: (params: ShareConversationNameParams, options?: ShareQueryOptions) => UseQueryResult<ConversationItem>
export const useInvalidateShareConversations: () => () => void

Import

import {
  shareQueryKeys,
  useGetWebAppInfo,
  useGetWebAppParams,
  useShareConversations,
  useShareChatList,
  useInvalidateShareConversations,
} from '@/service/use-share'

I/O Contract

Inputs

Name Type Required Description
code null Yes (access mode) Share code from the URL to check access mode
appSourceType AppSourceType Yes Source type: webApp, installedApp, or tryApp
appId string Conditional Required for installedApp source type
conversationId string Yes (chat list/name) Conversation ID to fetch messages or name for
lastId string No Last conversation ID for cursor-based pagination
pinned boolean No Filter for pinned conversations only
limit number No Number of conversations per page
enabled boolean No Override query enabled state
refetchOnWindowFocus boolean No Whether to refetch when the window gains focus
refetchOnReconnect boolean No Whether to refetch on network reconnect

Outputs

Name Type Description
AppConversationData AppConversationData Paginated conversation list with metadata
ConversationItem ConversationItem Conversation name and metadata
chat messages array Message list for the selected conversation

Usage Examples

import { useGetWebAppInfo, useShareConversations, useShareChatList, AppSourceType } from '@/service/use-share'

// Fetch web app info
const { data: appInfo } = useGetWebAppInfo()

// List conversations
const { data: conversations } = useShareConversations({
  appSourceType: AppSourceType.webApp,
  pinned: false,
  limit: 20,
})

// Fetch chat messages for a conversation
const { data: messages } = useShareChatList({
  conversationId: 'conv-123',
  appSourceType: AppSourceType.webApp,
})

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment