Platform-Specific Code
You can use different code on different platforms by specifying different file extensions.
See the tree shaking guide for more.
Video​
For a video walkthrough of using different code per-platform, see my 2021 Next.js Conf talk at about 21:53:
Example​
One example of platform-specific code is using @react-native-firebase
on Native, and firebase
on Web.
To see how this works, you can reference the source code from my 2022 Next.js Conf talk. Here's the Firebase section.