/fulcro-native-template

A sample template with a server, web, and native app.

Primary LanguageClojure

Fulcro Native Template

This repository is a work-in-progress.

This is a project that could be used as the basis for a full-stack Fulcro native+web project where the logic of the web and native apps is shared as much as possible.

This particular example shares login logic among the web and native UIs, along with some basic routing.

In the interest of time, a tour of this project is available on YouTube.

Basic Usage

Important
By default native app will try to connect to Electron Fulcro Inspect. You may comment out the app.inspect-native-preload in shadow-cljs.edn to disable this.
Note
Logging errors in the Native env will show an error screen on the app. Just press ESC to continue in the simulator if that happens.

In one terminal, start up expo:

$ cd mobile
$ yarn
$ expo start

In another terminal, start up CLJS build:

$ yarn
$ npx shadow-cljs server

Go to http://localhost:9630/dashboard and click on Builds, and check the native and web builds (you should see both of them build).

Make sure you have the clojure CLI tools installed, and in a 3rd terminal start a REPL:

$ clj -A:dev
user=> (restart)

You should see a message about starting.

Open http://localhost:3000. This is the webapp.

Go to the Expo terminal window and press 'i' (requires XCode and Simulator to be installed).

An iPad/Phone simulator should start with the app.

There is a demo login account of "user"/"letmein".

Usage on Android

If using Android you must use a patched version of sente and specify the host for Electron Fulcro Inspect.

Update deps.edn to use the patched version of sente

org.clojars.currentoor/sente        {:mvn/version "1.14.1-SNAPSHOT"}
com.fulcrologic/fulcro              {:mvn/version "3.1.8"
                                    :exclusions  [com.taoensso/sente]}

Update shadow-cljs.edn to connect to inspect on the host machine which is always 10.0.2.2 on the Android Studio emulator

:closure-defines  {'goog.DEBUG                  true
                                             app.client-native/SERVER_URL "http://10.0.2.2:3000/api-native"
                                             com.fulcrologic.fulcro.inspect.inspect_ws/SERVER_PORT 8237
                                             com.fulcrologic.fulcro.inspect.inspect_ws/SERVER_HOST "10.0.2.2"}