DEV Community

Cover image for A 2 years old alternative to React server components
Christian Mortaro
Christian Mortaro

Posted on

A 2 years old alternative to React server components

Over the last almost two years, I and my friends have been using a custom framework for our daily freelances.

Nullstack has the concept of server functions since day one and one of my favorite features of it is the fact that it only exposes the minimum required dependencies to the client bundle, but is still a fully capable SPA framework.

In the light of the recent posts about react server functions I decided to make a video explaining the solution we came up with.

This video is the last part of a playlist that describes the most used features of Nullstack in under 20 minutes.

The video shows step by step the mental process behind a demo with server components that works offline as well, but for those who just want to see some code, here is a quick example:

import Nullstack from 'nullstack';
import {readFileSync} from 'fs';
import {Remarkable} from 'remarkable';

class About extends Nullstack {

  readme = '';

  static async getReadme() {
    const text = readFileSync('README.md', 'utf-8');
    const md = new Remarkable();
    return md.render(text);
  }

  async initiate() {
    this.readme = await this.getReadme();
  }

  render() {
    return (
      <article html={this.readme} />
    )
  }

}

export default About;
Enter fullscreen mode Exit fullscreen mode

You can learn more about it in the Nullstack Documentation

Discussion (0)