npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@arietta-studio/appwrite-sdk

v1.6.0

Published

Appwrite SDK for TypeScript

Downloads

43

Readme

AppWrite SDK for React-Native

Changelog · Report Bug · Request Feature

📦 Installation

To install @arietta-studio/appwrite-sdk react-native-url-polyfill, run the following command:

$ bun add @arietta-studio/appwrite-sdk react-native-url-polyfill

Add your Platform

If this is your first time using Appwrite, create an account and create your first project.

Then, under Add a platform, add a Android app or a Apple app. You can skip optional steps.

iOS steps

Add your app name and Bundle ID. You can find your Bundle Identifier in the General tab for your app's primary target in XCode. For Expo projects you can set or find it on app.json file at your project's root directory.

Android steps

Add your app's name and package name, Your package name is generally the applicationId in your app-level build.gradle file. For Expo projects you can set or find it on app.json file at your project's root directory.

Setup

On index.js add import for react-native-url-polyfill

import 'react-native-url-polyfill/auto'

If you are building for iOS, don't forget to install pods cd ios && pod install && cd ..

Init your SDK

Add these values to .env file:

APPWRITE_ENDPOINT =
  APPWRITE_PLATFORM =
  APPWRITE_PROJECT_ID =
  APPWRITE_STORAGE_ID =
  APPWRITE_DATABASE_ID =
  APPWRITE_USER_COLLECTION_ID =
    'users';

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.

import { AppWriteProvider } from '@arietta-studio/appwrite-sdk';
import * as SplashScreen from 'expo-splash-screen';

const App = () => {
  const appWriteConfig = {
    endpoint: process.env.APPWRITE_ENDPOINT ?? 'https://cloud.appwrite.io/v1',
    platform: process.env.APPWRITE_PLATFORM ?? 'com.arietta.studio',
    projectId: process.env.APPWRITE_PROJECT_ID ?? 'appWrite-project',
    storageId: process.env.APPWRITE_STORAGE_ID ?? 'appWrite-storage',
    databaseId: process.env.APPWRITE_DATABASE_ID ?? 'appWrite-database',
    userCollectionId: process.env.APPWRITE_USER_COLLECTION_ID ?? 'users',
  };

  useEffect(() => {
    // Stop the Splash Screen from being hidden.
    const showSplashScreen = async () => {
      await SplashScreen.preventAutoHideAsync();
    };
    void showSplashScreen();
  }, []);

  return (
    <AppWriteProvider config={appWriteConfig}>
      <SafeAreaProvider>
        <NavigationContainer
          theme={{
            dark: true,
          }}
        >
          <MainRootStack />
        </NavigationContainer>
      </SafeAreaProvider>
    </AppWriteProvider>
  );
};

export default App;

Use in application

import { useAppWrite } from '@arietta-studio/appwrite-sdk';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import * as SplashScreen from 'expo-splash-screen';
import { type FC, useEffect } from 'react';

import Onboarding from '../pages/Onboarding';
import Profile from '../pages/Profile';
import HomeTabNavigator from './HomeTabNavigator';
import { ScreenNames } from './ScreenNames';

export type MainRootStackParams = {
  // Onboarding
  [ScreenNames.Onboarding]: undefined;

  // Home
  [ScreenNames.MainHome]: undefined;
  [ScreenNames.Profile]: undefined;
};
export const MainStack = createNativeStackNavigator<MainRootStackParams>();

export const MainRootStack: FC = () => {
  const { isAuthenticated, isAuthenticationLoading } = useAppWrite();

  useEffect(() => {
    // Once our data is ready, hide the Splash Screen
    const hideSplashScreen = async () => {
      await SplashScreen.hideAsync();
    };

    if (!isAuthenticationLoading) {
      void hideSplashScreen();
    }
  }, [isAuthenticationLoading]);

  return (
    <MainStack.Navigator initialRouteName={ScreenNames.MainHome}>
      {isAuthenticated ? (
        <MainStack.Group>
          <MainStack.Screen
            name={ScreenNames.MainHome}
            component={HomeTabNavigator}
            options={{ headerShown: false }}
          />
          <MainStack.Screen
            name={ScreenNames.Profile}
            component={Profile}
            options={{ headerShown: false }}
          />
        </MainStack.Group>
      ) : (
        <MainStack.Group>
          <MainStack.Screen
            name={ScreenNames.Onboarding}
            component={Onboarding}
            options={{ headerShown: false }}
          />
        </MainStack.Group>
      )}
    </MainStack.Navigator>
  );
};

Hook gives you these functions and variables

type AppWriteContextType = {
  signUp: (email: string, password: string, username: string) => Promise<Models.Document>;
  signIn: (email: string, password: string) => Promise<Models.Session>;
  signOut: () => Promise<void>;
  userRefresh: () => Promise<void>;
  updateUser: (newUser: Models.Document) => Promise<void>;
  isAuthenticated: boolean;
  user: Models.Document | undefined;
  isAuthenticationLoading: boolean;
  isUserDataRefreshing: boolean;
};

🤝 Contributing

Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub Issues to get stuck in to show us what you’re made of.