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

Docs: Add a "web support" section #88

Closed
gunnartorfis opened this issue Sep 12, 2024 · 9 comments · Fixed by #94
Closed

Docs: Add a "web support" section #88

gunnartorfis opened this issue Sep 12, 2024 · 9 comments · Fixed by #94
Labels
documentation Improvements or additions to documentation

Comments

@gunnartorfis
Copy link
Owner

Been receiving a few questions if this has web support.

Would want to point out to the following setup:

// sonner.ts
export * from 'sonner-native';
// sonner.web.ts
export * from 'sonner';

And mention that the APIs match so it will work on native & web platforms.

@gunnartorfis gunnartorfis added the documentation Improvements or additions to documentation label Sep 12, 2024
@Code-Victor
Copy link

Dope!
Awesome work.

@GustavoBonfimS
Copy link

When I try to add Sonner to my project and use it on the web, as you described, I encounter the following error: 'Unable to resolve "sonner" from "src/lib/Sonner/index.web.ts".'

Do you know how to solve this issue? Thank you for your great work!

@gunnartorfis
Copy link
Owner Author

Could you show me more code for context?

@GustavoBonfimS
Copy link

I created a basic reproduction example here:
https://github.com/GustavoBonfimS/sonner-native-web-test

In my tests, the only way to make Sonner work is by editing node_modules/sonner/package.json to include a main field. This way, I can run the web app with Sonner working.

@gunnartorfis
Copy link
Owner Author

@GustavoBonfimS thanks. Is platform specific file endings working in the project in general? If you just create some Text component that says "Hello" on native and "Hello Web" on .web.tsx?

@GustavoBonfimS
Copy link

Yes, I have platform-specific file extensions in other files in my app, and they worked fine before adding Sonner.

Could Sonner be breaking because of the Package Exports support in React Native? Are you able to use Sonner by following the setup in the documentation?

@gunnartorfis
Copy link
Owner Author

I'm using this setup in my production apps. There's one slight difference:

// toast.ts
export { toast, Toaster } from "sonner-native";
// toast.web.ts
export { toast, Toaster } from "sonner";

Could you try that instead of the * export?

@GustavoBonfimS
Copy link

This is causing errors as well 😢

What version of React Native are you using in your app? Could you try creating a new expo project and installing the library?

@gunnartorfis
Copy link
Owner Author

Seems like an open issue in Sonner: emilkowalski/sonner#473

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

Successfully merging a pull request may close this issue.

3 participants