nandorojo / solito

🧍‍♂️ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

Is it possible to enable "web" platform in the expo app? #322

Closed beepsoft closed 1 year ago

beepsoft commented 1 year ago

I created a sample app using

npx create-solito-app@latest -t with-expo-router

Everything works fine, but I started wondering if it possible to also enable the web platform in the expo app beside the ios and android platforms. I tried to enable it by adding "web" to "platforms" and configuring app.json to use the metro bundle (following the expo router documentation). This is my app.json:

{
  "expo": {
    "name": "solito-expo-router",
    "slug": "solito-expo-router",
    "version": "1.0.0",
    "scheme": "solito-expo-router",
    "platforms": ["ios", "android", "web"],
    "ios": {
      "bundleIdentifier": "com.solito.expo-router"
    },
    "web": {
      "bundler": "metro"
    }
  }
}

When I try to open the expo app in web it fails with an error like this:

Uncaught SyntaxError: Cannot use import statement outside a module (at index.bundle?platform=web&dev=true&hot=false:613:3)

all this around these lines in the bundle:

__d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
  "use strict";

  import 'expo-router/entry';
},0,[1],"index.js");

If this worked then I imagine we could have both a nextjs web app and an expo SPA web app using all the same components shared between nextjs and expo.

nandorojo commented 1 year ago

Solito isn’t made for that honestly. All the web side uses Next.js, and I’m not sure it’s a necessary use case to support 2 web frameworks

beepsoft commented 1 year ago

@nandorojo thanks for your response, I totally get that! Solito and expo router is already magical, and I didn't dig deeper into them to figure out how they work exactly, but thought if it is a simple fix it may worth it.

nandorojo commented 1 year ago

i’ll think about it, since it may be possible

0xBigBoss commented 1 year ago

i’ll think about it, since it may be possible

This would be awesome, as I'd like to use the simplify the navigation stack for our browser extension and could cut out our react-router-dom HashRouter.

Svarto commented 1 year ago

i’ll think about it, since it may be possible

Adding my voice - this would be a dream! Expo-Router + Solito 🤤

nandorojo commented 1 year ago

If that’s your preference, there’s no real need to use Solito. The main benefit of Solito is the Next.js integration. But you can just use Expo Router on Web if you want.

Solito already has an expo router example which uses it on native.

The request here is mostly an escape hatch. It does feel unlikely to work, though. But we’ll see, maybe in the future. Just feels low priority