Skip to content

Commit

Permalink
commit initial version of ndk-mobile (nostr-dev-kit#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablof7z authored Nov 20, 2024
1 parent a2bb478 commit fb3032d
Show file tree
Hide file tree
Showing 25 changed files with 5,373 additions and 2,147 deletions.
21 changes: 21 additions & 0 deletions ndk-mobile/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Pablo Fernandez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions ndk-mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# NDK Mobile

A React Native/Expo implementation of [NDK (Nostr Development Kit)](https://github.com/nostr-dev-kit/ndk) that provides a complete toolkit for building Nostr applications on mobile platforms.

## Features

- 🔐 Multiple signer implementations (NIP-07, NIP-46, Private Key)
- 💾 SQLite-based caching for offline support
- 🔄 Subscription management with automatic reconnection
- 📱 React Native and Expo compatibility
- 🪝 React hooks for easy state management
- 👛 Integrated wallet support

## Installation

npm install @nostr-dev-kit/ndk-mobile

## Usage

When using this library don't import `@nostr-dev-kit/ndk` directly, instead import `@nostr-dev-kit/ndk-mobile`. `ndk-mobile` exports the same classes as `ndk`, so you can just swap the import.

## Example

There is a barebones repository showing how to use this library:
[ndk-mobile-sample](https://github.com/pablof7z/ndk-mobile-sample).

For a real application using this look at [Olas](https://github.com/pablof7z/snapstr).

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Author

[@pablof7z](https://njump.me/f7z.io)
8 changes: 8 additions & 0 deletions ndk-mobile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import '@bacons/text-decoder/install';
import 'react-native-get-random-values';

export * from './src/hooks';
export * from './src/context';
export * from './src/providers';
export * from './src/cache-adapter/sqlite';
export * from '@nostr-dev-kit/ndk';
70 changes: 70 additions & 0 deletions ndk-mobile/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "@nostr-dev-kit/ndk-mobile",
"version": "0.1.2",
"description": "NDK Mobile",
"private": false,
"license": "MIT",
"peerDependencies": {
"expo": ">=51.0.0"
},
"devDependencies": {
"react-native-builder-bob": "^0.32.1",
"typescript": "^5.5.4"
},
"keywords": [
"ndk",
"nostr",
"react-native",
"expo"
],
"dependencies": {
"@bacons/text-decoder": "^0.0.0",
"@nostr-dev-kit/ndk": "workspace:*",
"@nostr-dev-kit/ndk-wallet": "workspace:*",
"react-native-get-random-values": "~1.11.0",
"zustand": "^5.0.1"
},
"source": "./index.ts",
"module": "./lib/module/index.js",
"react-native": "lib/module/index.js",
"exports": {
".": {
"import": {
"types": "./lib/typescript/module/index.d.ts",
"default": "./lib/module/index.js"
}
}
},
"scripts": {
"prepare": "bob build"
},
"files": [
"src",
"lib",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__"
],
"react-native-builder-bob": {
"source": "src",
"output": "lib",
"targets": [
[
"module",
{
"esm": true
}
],
[
"typescript",
{
"esm": true
}
]
]
},
"eslintIgnore": [
"node_modules/",
"lib/"
]
}
Loading

0 comments on commit fb3032d

Please sign in to comment.