Skip to content
backtickjsPublic

About

A toolchain for fully server-driven React Native apps.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

39 stars

Watchers

2 watching

Forks

Repository files navigation

Backtick: fully server-driven React Native.

npm license: MIT VS Code extension

What is Backtick?

Fully server-driven React Native. Write every screen in React, on your server: layout, data and behaviour. Changes ship with your next deploy, not your next app store release.

Website · Docs · VS Code extension · Discussions · X · Bluesky

Quick start

npx create-backtick-app@latest

It asks for a name, then creates an Expo app with a Backtick server beside it: run npm start, scan the QR code with your phone, and edit server/Home.tsx to change the screen. For a web page instead, pass --template react or --template solid-js; for a server on Bun, --runtime bun.

What it looks like

A screen can be made of server components, client components or both, like this one. The server component reads its data where it lives, and the client code sits inline, in a client script, cs`…`. Each splice, $name, is a value crossing from your server to the client, type-checked on both sides. Thinking in Backtick explains what runs where.

A server component, Home, that reads the user's usual order and returns a client script drawing a ScrollView with a greeting and, when there is one, a ReorderButton: a client component in the same file, with its own state.

The code, to copy
import { cs } from "@backtickjs/core";
import { useState } from "react" with { backtick: "client" };
import { Pressable, ScrollView, Text } from "react-native" with {
  backtick: "client",
};

// A server component: it runs on your server, for every request.
export async function Home({ user }: { user: User }) {
  const usual = await db.usualOrder(user.id);

  return cs`(
    <$ScrollView>
      <$Text>Good morning, {$user.name}</$Text>
      <$ReorderButton order={$usual} />
    </$ScrollView>
  )`;
}

// A client component, in the same file.
const ReorderButton = cs`(props: { order: Order }) => {
  const [added, setAdded] = $useState(false);
  return (
    <$Pressable onPress={() => setAdded(true)}>
      <$Text>{added ? "Added ✓" : "Reorder " + props.order.name}</$Text>
    </$Pressable>
  );
}`;

How it works

  • Compiled once. Client scripts are compiled at build time, and type-checked and formatted like the rest of your code.
  • Bundled per request. On each request, the bundler runs your server components and combines their data with the compiled scripts into one JavaScript file. Only the scripts a request rendered are in it, and data is written as data, never as code.
  • Run by the client. On the web, a page loads the bundle with a script tag and an import map. On React Native, your app fetches it and runs it with the React Native it already ships, so a server deploy is the release: users get your changes the next time they open the screen.

Packages

Package What it is
create-backtick-app Creates a project: React Native, React or Solid, on Node or Bun
@backtickjs/core The cs tag, and the types for what crosses to the client
@backtickjs/bundler Runs server components and bundles a screen per request
@backtickjs/expo Expo's compile step, and reloading the app when the server does
@backtickjs/jsx-react React's JSX for server components, and its compile step
@backtickjs/jsx-solid Solid's JSX for server components, and its compile step
@backtickjs/node-plugin Compiles scripts as a Node server loads them
@backtickjs/bun-plugin Compiles scripts as a Bun server loads them
@backtickjs/tspatch-plugin Compiles scripts when you build a server ahead of time with tspc
@backtickjs/tsc backtick-tsc: type-checks scripts and their splices
@backtickjs/prettier-plugin Formats the code inside scripts

Internal packages, used by the ones above: compiler, language-plugin, language-service, language-server and typescript-plugin.

Editor support

  • Backtick for VS Code highlights scripts as TSX, colours splices, and type-checks inside scripts.
  • backtick-tsc type-checks from the command line, and in CI.
  • The Prettier plugin formats scripts on save.

Who's behind it

I'm Jean-François Bisson. I spent a few years building mobile infrastructure at Meta before leaving to work on Backtick full time.

I love building things and moving fast, and Backtick is my attempt to make that easier for others too. If you're trying Backtick, thinking about server-driven UI, or just want to chat, I'd love to hear from you. Email me at jf@backtickjs.com, or find me on LinkedIn.

License

MIT

About

A toolchain for fully server-driven React Native apps.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

39 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages