The @state-less/clean-starter repository is designed to provide a starting point for developers exploring React Server. It includes essential backend components, utilities, and examples that illustrate the fundamental concepts and capabilities of React Server.
React Server allows the creation of server-side React components using TSX, promoting a component-driven architecture for building robust and maintainable backend solutions. By using @state-less/clean-starter, developers can quickly get started with this innovative approach to full-stack development.
For detailed documentation and in-depth guides, please visit the official website at state-less.cloud.
Getting Started
Backend
To get started on the backend, you can initialize a new project with the following commands:
git clone https://github.com/state-less/clean-starter.git -b react-server my-server
This command will set up a new project with the necessary dependencies and configuration files. Navigate into the newly created directory and start the development server:
cd my-server
git remote remove origin
yarn install
yarn start
This will launch the development server, allowing you to access your GraphQl endpoint at http://localhost:4000/graphql.
Client
Get a Client running
Create a new vite project and choose React as framework and TypeScript as variant.
Now go to the newly created folder, install the dependencies and add @apollo/client
and state-less/react-client
to your project and start the server.
cd vite-project
yarn
yarn add @apollo/client state-less/react-client
yarn dev
If you click the button, you will see the counter increase, but if you reload the page, the counter resets to 0. Let’s connect the state to our backend to make it serverside and persist over page reloads.
Instantiate a GraphQl client
In order to connect to our backend, we need to create a GraphQl client. Create a new file under /src/lib/client.ts
and paste the following content.
Note: For now you need to manually create this file, but it will later be created by an initializer or react-client wil