Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying Storage #96

Open
Nikola-Milovic opened this issue Apr 18, 2023 · 2 comments
Open

Add support for specifying Storage #96

Nikola-Milovic opened this issue Apr 18, 2023 · 2 comments

Comments

@Nikola-Milovic
Copy link

It would be a nice option to be able to specify the storage type as long as it adheres to the Storage interface

for example, it would allow us to integrate expo-secure-store

import SuperTokens from 'supertokens-react-native';
import * as SecureStore from "expo-secure-store";
import "react-native-url-polyfill/auto";

const ExpoSecureStoreAdapter = {
	getItem: (key: string) => {
		return SecureStore.getItemAsync(key);
	},
	setItem: (key: string, value: string) => {
		SecureStore.setItemAsync(key, value);
	},
	removeItem: (key: string) => {
		SecureStore.deleteItemAsync(key);
	},
};

SuperTokens.init({
	apiDomain: "<YOUR_API_DOMAIN>",
	apiBasePath: "/auth",
	storage: ExpoSecureStoreAdapter
});

From the GoTrue JS SDK , this is the type they allow as storage

https://github.com/supabase/gotrue-js/blob/master/src/lib/types.ts#L48
https://github.com/supabase/gotrue-js/blob/master/src/lib/types.ts#L929

This would be a nice to have, it would possibly allow merging the supertokens libraries into a single supertokens-js library instead of having multiple implementations for RN and Web separately. Thoughts?

@rishabhpoddar
Copy link
Contributor

These are excellent changes. We will consider these when we have more bandwidth. That being said, feel free to open a PR in our existing react native SDK to add this feature.

@iway1
Copy link

iway1 commented Nov 3, 2023

this would be cool.. react-native-mmkv would be a great option as it is the fastest persistence library and is fully synchronous. Maybe that allows making some of the async methods in the library synchronous?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants