Implementation:Langgenius Dify UseEducation
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Education, Account Management |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
React Query hooks for managing education verification and student status in Dify, including verification, application submission, institution autocomplete, and status queries.
Description
The UseEducation module provides TanStack React Query hooks for Dify's education program API. The education program allows verified students to access special pricing tiers or benefits. The module includes hooks for verifying education eligibility (useEducationVerify returns a token), submitting an education application (useEducationAdd), autocompleting educational institution names during the application process (useEducationAutocomplete), querying the current student verification status with expiry information (useEducationStatus), and invalidating the cached education status after changes (useInvalidateEducationStatus).
Usage
Use these hooks in the Dify education application flow and account settings to verify student status, submit education verification applications, and display the current education tier status.
Code Reference
Source Location
- Repository: Langgenius_Dify
- File: web/service/use-education.ts
Signature
export const useEducationVerify: () => UseMutationResult<{ token: string }>
export const useEducationAdd: (opts: { onSuccess?: () => void }) => UseMutationResult<{ message: string }, unknown, EducationAddParams>
export const useEducationAutocomplete: () => UseMutationResult<{ data: string[], has_next: boolean, curr_page: number }, unknown, SearchParams>
export const useEducationStatus: (disable?: boolean) => UseQueryResult<{ is_student: boolean, allow_refresh: boolean, expire_at: number | null }>
export const useInvalidateEducationStatus: () => () => void
Import
import {
useEducationVerify,
useEducationAdd,
useEducationAutocomplete,
useEducationStatus,
useInvalidateEducationStatus,
} from '@/service/use-education'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| params | EducationAddParams |
Yes (add mutation) | Education application submission parameters |
| searchParams.keywords | string |
No | Search keyword for institution autocomplete |
| searchParams.page | number |
No | Page number for autocomplete pagination (default 0) |
| searchParams.limit | number |
No | Results per page for autocomplete (default 40) |
| disable | boolean |
No | Disable the education status query |
| onSuccess | () => void |
No | Callback invoked after successful education application |
Outputs
| Name | Type | Description |
|---|---|---|
| token | string |
Verification token returned from the education verify endpoint |
| message | string |
Success message after submitting an education application |
| is_student | boolean |
Whether the user is a verified student |
| allow_refresh | boolean |
Whether the user can refresh their education verification |
| expire_at | null | Unix timestamp when the education verification expires |
| data | string[] |
List of matching institution names from autocomplete |
| has_next | boolean |
Whether more autocomplete results are available |
Usage Examples
import { useEducationStatus, useEducationAdd, useEducationAutocomplete } from '@/service/use-education'
// Check student status
const { data: status } = useEducationStatus()
if (status?.is_student) {
console.log('Student verified, expires at:', status.expire_at)
}
// Autocomplete institution search
const { mutateAsync: autocomplete } = useEducationAutocomplete()
const results = await autocomplete({ keywords: 'MIT', page: 0, limit: 10 })
// Submit education application
const { mutate: submitApplication } = useEducationAdd({
onSuccess: () => console.log('Application submitted'),
})
submitApplication({ institution: 'MIT', email: 'student@mit.edu' })
Related Pages
- Langgenius_Dify_Fetch_Layer - Underlying HTTP fetch layer for API requests