maseunghyun-react-native-config-bridge
v1.0.0
Published
TypeScript types and React Native implementation for WebView bridge communication
Downloads
5
Maintainers
Readme
@MaSeungHyun/react-native-config-bridge
React Native와 WebView 간 통신을 위한 TypeScript 타입 정의 전용 패키지
📦 설치
npm install @MaSeungHyun/react-native-config-bridge🚀 사용법
타입만 사용 (웹 프로젝트에서)
import { type BridgeState, type AppBridge } from '@MaSeungHyun/react-native-config-bridge';
import { linkBridge } from '@webview-bridge/web';
const bridge = linkBridge<AppBridge>();
// 완벽한 타입 추론과 자동완성!
bridge.setToken('abc123');
bridge.getMessage();
bridge.openInAppBrowser('https://example.com');React Native에서 사용
import { type BridgeState, type AppBridge } from '@MaSeungHyun/react-native-config-bridge';
import { bridge } from '@webview-bridge/react-native';
// 타입을 활용해서 직접 구현
const appBridge = bridge<BridgeState>({
token: '',
async setToken(token) {
// 구현...
},
async getMessage() {
return "I'm from native";
},
async openInAppBrowser(url) {
// 구현...
}
});📋 지원하는 메서드
setToken(token: string): 토큰 설정getMessage(): 네이티브에서 메시지 받기openInAppBrowser(url: string): 인앱 브라우저 열기
🔧 개발
# 타입만 배포하므로 빌드 불필요!
npm publish --dry-run # 테스트
npm publish # 실제 배포📄 License
MIT
