0.1.6 • Published 6 months ago

@icarus00x/react-native-appwrite-expo-newarch v0.1.6

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
6 months ago

Appwrite React Native SDK - New Architecture Fix

This repository is a fork of the official Appwrite React Native SDK, specifically created to address TurboModule errors that occur when using the New Architecture in React Native.

Background

Appwrite is a powerful backend platform for web and mobile applications. This fork exists as a temporary solution to resolve compatibility issues that emerged when testing applications after upgrading Expo and enabling the New Architecture.

Note: This is a temporary workaround, not an official upgrade. Please use with caution and refer to the official repository for regular updates and maintenance.

Why This Fork Exists

This package specifically addresses compatibility issues with the New Architecture in React Native. The modifications focus on resolving errors originating from src/client.ts by providing alternative module implementations.

Current Status

This fork has been tested and works in production applications, but should be considered a temporary solution until the official SDK is updated.

Fix Details

Two approaches have been tested:

  1. Using Expo Device Module:

    import * as Device from 'expo-device';
    
    this.realtime.socket = new WebSocket(url, undefined, {
        headers: {
            Origin: `appwrite-${Device.osName}://${this.config.platform}`
        }
    });

    This solution was found to be inconsistent on certain Android devices where Device.osName returns unexpected values.

  2. Using Expo Constants: This is the current implementation which has been tested successfully across 7 devices (including 3 iOS devices) without errors.

Installation

npx expo install @icarus00x/react-native-appwrite-expo-newarch react-native-url-polyfill

Setup Guide

1. Import URL Polyfill

In your index.js file, add:

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

iOS Note: Remember to install pods with cd ios && pod install && cd ..

2. Initialize the SDK

import { Client } from 'react-native-appwrite';

const client = new Client();

client
    .setEndpoint('https://your-endpoint/v1') // Your Appwrite Endpoint
    .setProject('your-project-id')           // Your project ID
    .setPlatform('com.example.yourapp')      // Your application ID or bundle ID
;

3. Make Your First Request

import { Client, Account, ID } from 'react-native-appwrite';

const client = new Client();
client
    .setEndpoint('https://your-endpoint/v1')
    .setProject('your-project-id')
    .setPlatform('com.example.yourapp')
;

const account = new Account(client);

// Register User
account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe')
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.log(error);
    });

Platform Configuration

Before using this SDK, you'll need to configure your application in the Appwrite Console:

  1. Create an account and project in Appwrite if you haven't already
  2. Add your platform (Android or iOS)

For iOS

  • Add your app name and Bundle ID (found in XCode under the General tab or in app.json for Expo projects)

For Android

  • Add your app name and package name (typically the applicationId in your app-level build.gradle file or in app.json for Expo projects)

Additional Resources

Contributing

This fork is maintained as a temporary solution. For long-term fixes, please consider contributing to the official SDK repository following their contribution guidelines.

License

This project is licensed under the BSD-3-Clause license.

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago