• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

experimental renderer for preact to work with react-native

preact-native

Warning: This is an experimental approach at creating a renderer for preact

Note: untill this reaches v1.0.0, the entire featureset might change, since we are still figuring out what works best

I wouldn't really recommend using this for production but putting down the base usage setup so that anyone who'd wish to help with development can at least get a test environment ready.

Install

$ npm install @barelyhuman/preact-native preact

Usage

  1. Setup a base react native project using npx react-native init
  2. Change index.js to include the withPreact from the library
/**
 * @format
 */
import { AppRegistry } from 'react-native'
import App from './App'
import { name as appName } from './app.json'
import { withPreact } from '@barelyhuman/preact-native'

AppRegistry.registerComponent(appName, () => withPreact(App))
  1. Then add the following to the top of the App.js file
/** @jsxImportSource preact */
import { SafeAreaView, View, Text, TextInput } from '@barelyhuman/preact-native'
  1. Once the above is setup, you can just go ahead and write preact components as usual.

Note: instead of preact/hooks please use @preact/signals for the time being, once fixed this note will be removed

Eg:

/** @jsxImportSource preact */
import { SafeAreaView, View, Text } from '@barelyhuman/preact-native'

export default function App() {
  return <Home />
}

function Home() {
  return (
    <>
      <SafeAreaView>
        <View>
          <Text color={'red'}>Hello</Text>
        </View>
      </SafeAreaView>
    </>
  )
}

Note: All react related stuff (react as a dep and render tree needing react) will be removed from the library once I can handle creation of all these native modules manually without having to re-write the entire react native base from scratch

Roadmap

  • A minimal dom
  • Create views from the bridge instead of rendering with react
    • Create native views (Views created on the iOS and Android platform APIs)
    • Create derived views (Views created on top of the above by manipulating the SDK)
  • Update view styles from the bridge
  • Update text nodes from the bridge
  • Add compat for preact to make it possible for preact to diff and render without the need for a react tree generator import {render} from "preact-native/dom"
  • Handle events (presses, input, gestures) , aka events from preact will be on the DOM, need to be proxied as events to the Native SDK
  • Handling for Bridge level style props

Contribute

read the CONTRIBUTING.md

Why ?

It seemed like a nice project to try out my limits in terms of complicated stuff and also because I got bored of building websites. Also, I personally think preact has become a lot more stable and has less breaking changes every 3 versions thus making it easier to maintain and upgrade older projects.

License

MIT ยฉ reaper

More Repositories

1

goblin

Golang binaries compiled on-demand for your system
Go
91
star
2

commitlog

Generate Changelogs from Commits (CLI)
Go
74
star
3

mark

Quick Web Markdown Editor
Vue
30
star
4

alvu

tiny little scriptable static site generator
Go
20
star
5

preact-islands-diy

DIY Starter Template for a more verbose island setup with existing tools instead of a framework
JavaScript
18
star
6

thestack

Blocks of backend libraries/tech squashed together
TypeScript
18
star
7

preact-island-plugins

Collection of low level plugins for different bundlers to generate and handle preact islands
JavaScript
15
star
8

adex

An easier way to build apps with Vite and Preact
JavaScript
14
star
9

prev-nitro

Tiny Island Boilerplate for Preact Islands and Nitro
JavaScript
11
star
10

custom-rom-index

Community Sourced Android Custom ROM Index
JavaScript
11
star
11

froutes

A minimal file tree based api router for node rest api's.
JavaScript
10
star
12

mage

stateful + logical abstraction layer for react
TypeScript
10
star
13

music

Minimal music player, uses Youtube for tracks
Vue
9
star
14

preact-islands-fullstack-template

Starter Template for fullstack apps with preact islands
JavaScript
9
star
15

tiny-use

The tiniest middleware library for node's standard HTTP library
TypeScript
9
star
16

conch

micro library for async sequential batches (Node/Browser/Deno) , for low memory systems
JavaScript
8
star
17

temp-cli

mac os x m1 temperature check cli
Objective-C
7
star
18

sizesnap

Simple file size snapshot generator
JavaScript
7
star
19

babel-plugin-mutable-react-state

(WIP) transform mutable variables to react-state
TypeScript
7
star
20

backend-go

Go
6
star
21

esbuild-multicontext

Minimal wrapper over esbuild's context API
TypeScript
6
star
22

nomen

minimalistic but extensible framework for server-rendered applications
JavaScript
6
star
23

hen-experimental

Different Approaches at preview for Hen
JavaScript
6
star
24

useless

A set of useless utilities for javascript
TypeScript
6
star
25

mudkip

The non-customizable markdown to html CLI (another documentation generator)
Nim
6
star
26

typeapi

JavaScript
6
star
27

prev

JavaScript
6
star
28

typer

JavaScript
5
star
29

adex-default-template

Default template for https://github.com/barelyhuman/adex
JavaScript
5
star
30

tom-nitro-preact

CSS
5
star
31

filesizemd

file's sizes as a markdown table (CLI)
C
5
star
32

nuxt-module-preact-islands

TypeScript
5
star
33

tocolor

Tiny color conversion library
TypeScript
5
star
34

notdone

Tiny grouped checklists ( as a daemon )
Go
4
star
35

spotify-lite-go

Simple Spotify Client built in go
Go
4
star
36

plum-js

JavaScript
4
star
37

reaper.is

Reaper Blog
Lua
4
star
38

range

availability ranges as a tiny little library
TypeScript
4
star
39

pkg

JavaScript
4
star
40

typeable

a on-the-fly type generator for objects in node
JavaScript
4
star
41

adminer-nord

Nord Styled Themes for adminer
CSS
3
star
42

civet-web

Tiny web playground for civet
CSS
3
star
43

hen

UI Component Playground - React
JavaScript
3
star
44

conrou

Controller bound Routes
JavaScript
3
star
45

react-async

async utilities for react (hooks, views, and more)
JavaScript
3
star
46

mark-mac

Swift
3
star
47

easy-deploy-template

Go
3
star
48

hes

hasura express server example
JavaScript
3
star
49

real-app-islands-diy

A simple real worlds CRUD app with https://github.com/barelyhuman/preact-islands-diy
JavaScript
3
star
50

commitlog-web

Web Interface for commitlog
HTML
3
star
51

baadal

API to the clouds - a batteries included setup for generative API's + a modern monolith
TypeScript
3
star
52

background-timer

React hook to run a timer in the background
TypeScript
3
star
53

uvu-inline-snapshot

Minimal Inline Snapshot utility for uvu/assert http://github.com/lukeed/uvu
JavaScript
3
star
54

music-fresh

https://github.com/barelyhuman/music but with deno's fresh
TypeScript
2
star
55

wallsync

Wallpaper switcher for macOS
Swift
2
star
56

nimclog

a smaller and tightly scoped version of commitlog
Nim
2
star
57

pipe

An adaptable and tiny pipe utility
TypeScript
2
star
58

style-builder

Variant based CSS-in-JS library (low-level)
JavaScript
2
star
59

delif

tiny delete with filters
Nim
2
star
60

barelyhuman.dev

Official barelyhuman.dev website
Vue
2
star
61

hits

Simple Page Hits Counter (Not an alternative to analytics)
Crystal
2
star
62

minzsh

Ultra minimal native zsh theme
Shell
2
star
63

dveep

Minimalistic and Straightforward Preact Islands
JavaScript
2
star
64

bun-pris-example

example app with bun and preact-islands-plugins
JavaScript
2
star
65

bh-pocketbase-docker

Simple docker-compose + Dockerfile for self hosting Pocketbase inside docker
Shell
2
star
66

react-native-swipeable-scrollview

Simpler bottom sheet using scrollviews
TypeScript
2
star
67

mono

My monorepo templates , with an additional ESM supported setup
JavaScript
2
star
68

http

JavaScript
2
star
69

musync

Simple Spotify Library to Playlist Sync
Go
2
star
70

urql-generic-requester

GraphQL Codegen Generic SDK Requester creator for URQL Client
TypeScript
2
star
71

httpsdk

JavaScript
2
star
72

dokcli

Setup dokku apps with generated scripts
Go
2
star
73

stone

A hackable CSS-in-JSS and Theming solution
TypeScript
2
star
74

jsrepl

A Quick and Minimal JS REPL
TypeScript
2
star
75

goalist-mutable-react-example

experimental project for babel-plugin-mutable-react-state
JavaScript
1
star
76

react-apex-renderer-example

JavaScript
1
star
77

grdn

Digital Garden
1
star
78

hexa-mono

Monorepo with a loosely implemented hexagonal arch
TypeScript
1
star
79

astring-jsx

A wrapper around https://www.npmjs.com/package/astring, adding JSX support
JavaScript
1
star
80

cyclejs-reactnative-workhouse

Repo to experiment and build stuff for the cyclejs react native driver
Java
1
star
81

statico

A static site generator for creative devs
Go
1
star
82

gitscaff

simple scaffolding with git repositories
JavaScript
1
star
83

react-native-starter

Stay Away! Personal Starter
Java
1
star
84

knex-studio

JavaScript
1
star
85

docker-caddy-example

container applications with Caddy + docker compose
Shell
1
star
86

minweb-public-data

Public Data for https://minweb.site/
JavaScript
1
star
87

wait-till-done

TypeScript
1
star
88

todo-challege-30-min

TypeScript
1
star
89

vite-ssr-preact-repro

JavaScript
1
star
90

fontlogo

for when i'm too lazy to design a logo
JavaScript
1
star
91

setup-eslint

wrapper CLI for a flexible eslint setup
JavaScript
1
star
92

boiled

docker and nodejs based backend boilerplate
JavaScript
1
star
93

nimtemplate

my simple nim lang template
Nim
1
star
94

fs-route-manifest

TypeScript
1
star
95

timestamps

A tiny timestamp parsing and formatting library (Node, Deno, ESM)
JavaScript
1
star
96

wasm-colors

JavaScript
1
star
97

vscode.quickpanel

custom css + js for vscode quickpanel for a spotlight like panel
JavaScript
1
star
98

go

Reusable utilities for golang
Go
1
star
99

onix-i

TillWhen
JavaScript
1
star
100

macscreens

Mac Display Layout Manager (CLI)
Go
1
star