Skip to main content

Build full-stack web applications with Jac - one language for frontend and backend.

Project description

Jac Client

Build full-stack web applications with Jac - one language for frontend and backend.

Jac Client enables you to write React-like components, manage state, and build interactive UIs all in Jac. No need for separate frontend frameworks, HTTP clients, or complex build configurations.


Features

  • Single Language: Write frontend and backend in Jac
  • No HTTP Client: Use jacSpawn() instead of fetch/axios
  • React Hooks: Use standard React useState and useEffect hooks (useState is auto-injected when using has variables)
  • Component-Based: Build reusable UI components with JSX
  • Graph Database: Built-in graph data model eliminates need for SQL/NoSQL
  • Type Safety: Type checking across frontend and backend
  • Vite-Powered: Optimized production bundles with Vite

Quick Start

Installation

pip install jac-client

Create a New App

jac create --cl my-app
cd my-app
jac start src/app.jac

Visit http://localhost:8000 to see your app! (The app component is served at the root by default.)

You can also access the app at http://localhost:8000/cl/app.

Note: The --cl flag creates a client-side project with an organized folder structure. Without --cl, jac create creates a standard Jac project.


Documentation

For detailed guides and tutorials, see the docs folder:

  • Getting Started Guide - Complete beginner's guide
  • Routing - Multi-page applications with declarative routing (<Router>, <Routes>, <Route>)
  • Lifecycle Hooks - Using React hooks (useState, useEffect)
  • Advanced State - Managing complex state with React hooks
  • Imports - Importing third-party libraries (React, Ant Design, Lodash), Jac files, and JavaScript modules

Example

Simple Counter with React Hooks

# Note: useState is auto-injected when using has variables in cl blocks
# Only useEffect needs explicit import
cl import from react { useEffect }

cl {
    def Counter() -> any {
        # useState is automatically available - no import needed!
        [count, setCount] = useState(0);

        useEffect(lambda -> None {
            console.log("Count changed:", count);
        }, [count]);

        return <div>
            <h1>Count: {count}</h1>
            <button onClick={lambda e: any -> None {
                setCount(count + 1);
            }}>
                Increment
            </button>
        </div>;
    }

    def app() -> any {
        return Counter();
    }
}

Note: When using has variables in cl {} blocks or .cl.jac files, the useState import is automatically injected. You only need to explicitly import other hooks like useEffect.

Full-Stack Todo App

# useState is auto-injected, only import useEffect
cl import from react { useEffect }
cl import from '@jac-client/utils' { jacSpawn }

# Backend: Jac nodes and walkers
node Todo {
    has text: str;
    has done: bool = False;
}

walker create_todo {
    has text: str;
    can create with `root entry {
        new_todo = here ++> Todo(text=self.text);
        report new_todo;
    }
}

walker read_todos {
    can read with `root entry {
        visit [-->(`?Todo)];
    }
}

# Frontend: React component
cl {
    def app() -> any {
        # useState is automatically available - no import needed!
        [todos, setTodos] = useState([]);

        useEffect(lambda -> None {
            async def loadTodos() -> None {
                result = await jacSpawn("read_todos", "", {});
                setTodos(result.reports);
            }
            loadTodos();
        }, []);

        return <div>
            <h1>My Todos</h1>
            {todos.map(lambda todo: any -> any {
                return <div key={todo._jac_id}>{todo.text}</div>;
            })}
        </div>;
    }
}

Requirements

  • Python: 3.12+
  • Node.js: For npm and Vite
  • Jac Language: jaclang (installed automatically)

️ How It Works

Jac Client is a plugin that:

  1. Compiles your .jac client code to JavaScript
  2. Bundles dependencies with Vite for optimal performance
  3. Provides a runtime for reactive state and components
  4. Integrates seamlessly with Jac's backend graph operations

Learn More

  • Full Documentation: See docs/ for comprehensive guides
  • Examples: Check jac_client/examples/ for working examples
  • Issues: Report bugs on GitHub Issues

License

MIT License - see LICENSE file.


Happy coding with Jac!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jac_client-0.2.7.tar.gz (83.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jac_client-0.2.7-py3-none-any.whl (117.8 kB view details)

Uploaded Python 3

File details

Details for the file jac_client-0.2.7.tar.gz.

File metadata

  • Download URL: jac_client-0.2.7.tar.gz
  • Upload date:
  • Size: 83.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jac_client-0.2.7.tar.gz
Algorithm Hash digest
SHA256 cc1dffe1383d71047300fbe60c804f8922bc7d2bf9e7817564d262f4dedf672e
MD5 9e17ae18540e798763691cc7ff1e5e03
BLAKE2b-256 dc9d719bc2a6b6653b67831f646a0c733e6fbe42c45dd13502165ddfcf48e7a5

See more details on using hashes here.

File details

Details for the file jac_client-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: jac_client-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 117.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jac_client-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8533e78ece6ac3edab7041700f857fefa6fad5f428538f8db02281439a9285bc
MD5 9dd92ed9050ed106d4d01e1659c88df1
BLAKE2b-256 6d4c0f4e5b8517a0ac6b55b5ddb6a1564844b063c2d99b4919544e0abcaa507d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page