DEV Community

Discussion on: A road to the easiest user authentication system for Node.js

Collapse
 
saltyshiomix profile image
Shiono Yoshihide

Thanks Igor!

Feel free to open issues if you have any troubles :)

By the way, I'm currently working on react-ssr, which is an alternative to NEXT.js. (I think)

This renders React as a view template engine of Express like this:

// server.js
const posts = [
  { id: 1, body: 'This is a first post.' },
  { id: 2, body: 'This is a second post.' },
  { id: 3, body: 'This is a last post.' },
];

app.get('/', (req, res) => {
  res.render('index', { posts });
});
// views/index.jsx
import React from 'react';

const IndexPage = ({ posts }) => {
  return (
    <React.Fragment>
      {posts.map((post, index) => {
        return (
          <p key={index}>
            <a href={'/posts/' + post.id}>{post.body}</a>
          </p>
        );
      })}
    </React.Fragment>
  );
};

export default IndexPage;

If you like, please try it :)

Thank you in advance!

Yoshihide