@namnguyen.repl.it/nn-core
v0.1.4
Published
Core utilities for NN apps
Readme
nn-core
Reusable core modules for React / React Native apps — auth, networking, storage, push notifications, i18n, theming, modals, screen utilities, and auth flow state machines.
Install
npm install nn-coreModules
| Module | Import | Platform | Description |
| ---------------------------------------- | ------------------- | -------- | ---------------------------------------------------- |
| auth | nn-core/auth | Any | Auth provider, token management, auto-refresh |
| network | nn-core/network | Any | HTTP client, route-based API caller, request signing |
| storage | nn-core/storage | Any | Cross-platform storage & crypto adapters |
| push | nn-core/push | RN | Push notification provider with pub/sub |
| language | nn-core/language | Any | i18n provider (i18next) |
| theme | nn-core/theme | Any | Generic theme provider with persistence |
| modal | nn-core/modal | RN | Bottom sheets, popups, notifications |
| screen | nn-core/screen | RN | ScrollView wrapper, animations, sortable list |
| auth-flow | nn-core/auth-flow | Any | Login/register/social auth state machines |
| hooks | nn-core/hooks | Any | useSubmit, usePaging, useToggle |
| utils | nn-core/utils | Any | Currency, delay, number formatting, polling |
Quick Start
import { createAuthClient, AuthProvider, useAuth } from "nn-core/auth";
import { createAsyncStorageAdapter } from "nn-core/storage";
import { LanguageProvider } from "nn-core/language";
import { ThemeProvider } from "nn-core/theme";
import { ModalProvider } from "nn-core/modal";
const authClient = createAuthClient({
baseURL: "https://api.example.com",
routes: {
/* ... */
},
storage: createAsyncStorageAdapter(AsyncStorage),
});
function App() {
return (
<AuthProvider client={authClient}>
<LanguageProvider config={{ defaultLanguage: "en", resources }}>
<ThemeProvider config={{ themes, defaultVariant: "default" }}>
<ModalProvider>
<MainApp />
</ModalProvider>
</ThemeProvider>
</LanguageProvider>
</AuthProvider>
);
}Architecture
nn-core/
├── auth/ # AuthProvider + createAuthClient + tokenStore
├── network/ # HttpClient + apiCaller + requestSigner
├── storage/ # StorageAdapter + CryptoAdapter implementations
├── push/ # PushNotificationProvider
├── language/ # LanguageProvider (i18next)
├── theme/ # ThemeProvider<T> (generic)
├── modal/ # ModalProvider + SlideUp + PopUp + Notifications
├── screen/ # ScreenWrapper + AnimateLayout + SortableList
├── auth-flow/ # useLoginFlow + useRegisterFlow + useSocialAuth
├── hooks/ # useSubmit + usePaging + useToggle
└── utils/ # delay + currency + number + miscDesign Principles
- Adapter pattern — no hard dependencies on AsyncStorage, Firebase, etc., apps inject their own
- Generic types —
ThemeProvider<T>accepts any shape,APICaller<TRoutes>is type-safe - Imperative APIs —
SlideUp().open(...)callable from anywhere without hooks - Pure state machines — auth-flow hooks return
[state, actions], zero UI coupling - Tree-shakeable — import only what you need via subpath exports
Peer Dependencies
All optional except react:
| Dependency | Required by |
| ------------------------------ | ------------------- |
| react | All modules |
| axios | auth, network |
| i18next | language |
| react-i18next | language |
| react-native | push, modal, screen |
| react-native-reanimated | modal, screen |
| react-native-gesture-handler | modal, screen |
License
MIT
