null if no tampering has been detected.
This hook handles both pre-mount and runtime tamper detection transparently:
- Tamper at module load (before React mounted) - state is pre-filled from buffered value
- Tamper at runtime - state updates via subscription when integrity check fails
Signature
Returns
The storage key that failed integrity verification, or
null if no tampering detected. Possible values include:"unlocked"- The unlocked achievements data was tampered with"progress"- The progress data was tampered with"items"- The collected items data was tampered withnull- No tampering detected
Usage
Basic tamper detection
Logging tamper events
Displaying detailed tamper information
How it works
WhencreateAchievements() detects tampered data (via hash mismatch), it:
- Calls your
onTamperDetectedcallback (if provided) - Wipes all achievement storage atomically
- Notifies any mounted
useTamperDetected()hooks - Buffers the tamper key for hooks that mount later
Notes
This hook is only available from the factory-bound hooks returned by
createAchievements(). It’s not a standalone hook you import separately.Tamper detection is a friction layer, not cryptographic security. A determined user can still forge both the data and its hash. Use server-side validation for security-critical achievements.
See also
- createAchievements - Factory that returns this hook
- Anti-cheat - Overview of tamper detection system
- Hash Adapters - Custom hash functions for integrity checking
