@myatthirikhin/chat-expo
v0.1.0
Published
Expo media capture for @myatthirikhin/chat-react-native — photos, documents and voice messages.
Downloads
161
Readme
@myatthirikhin/chat-expo
Media capture for @myatthirikhin/chat-react-native: photos, documents and voice messages,
built on Expo modules.
Optional. Skip it and the composer renders without attach or mic buttons — which is exactly what a bare React Native app with no media modules should get.
pnpm add @myatthirikhin/chat-expo
npx expo install expo-image-picker expo-document-picker expo-image-manipulator expo-audioUse
import { createExpoFilePicker, useExpoAudioRecorder } from '@myatthirikhin/chat-expo';
const filePicker = createExpoFilePicker();
function App() {
// A HOOK, unlike the picker — see below.
const recorder = useExpoAudioRecorder();
return (
<ChatProvider client={chat} filePicker={filePicker} recorder={recorder}>
<ChatScreen conversationId={id} myId={me} />
</ChatProvider>
);
}Why one is a factory and the other is a hook
IAudioRecorder is an imperative interface precisely so implementations aren't forced to be
hooks. This one has to be anyway: expo-audio exports AudioRecorder as a type only, and
useAudioRecorder() is the only runtime way to obtain an instance.
A future recorder built on something else can be a plain factory without changing the port.
Why this is a separate package
peerDependenciesMeta.optional is a package-manager contract that Metro does not read. An
unresolvable static import is a hard bundling failure, not a runtime undefined, and even a
try/catch require emits resolution warnings. Splitting the Expo-dependent code into its own
package is the only way to make attachments genuinely optional.
It also matters for adoption: installing expo in a bare React Native CLI app requires
npx install-expo-modules and an iOS deployment target of 16.4. That's a real cost, and no
consumer should pay it just to render text messages.
Bare React Native CLI
These are ordinary Expo modules, so they work outside Expo — you just have to install the runtime first:
npx install-expo-modules@latestSee Expo's guide. Note the iOS 16.4 floor.
Peers
expo-image-picker · expo-document-picker · expo-image-manipulator · expo-audio · react
Deliberately loose version ranges (*): Expo module versions are pinned to the consumer's SDK, and
a narrow range here would block every SDK upgrade.
License
MIT
