Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Add a render method like Next JS #1408

Open
@lamualfa

Description

@lamualfa

Is your feature request related to a problem? Please describe.

Small applications that use the concept of monoliths often use the API server, Frontend server and other logic in a single project. I have a little trouble to do the separation of the many routes if using the file routing concept.

Describe the solution you'd like

in Next JS, we can create a custom server using anything (like Fastify, Express, Koa, etc), then create a special handler that is used to render the React page. Next JS has its own render method which can be called from anywhere. Does Sapper have a plan to implement the same to render a Svelte page?

Example using render method in NextJS :

createServer((req, res) => {
    const parsedUrl = parse(req.url, true)
    const { pathname, query } = parsedUrl

    if (pathname === '/a') {
      // NextJS render method
      app.render(req, res, '/a', query)
    } else if (pathname === '/b') {
      // NextJS render method
      app.render(req, res, '/b', query)
    } else {
      // Other handler
      handle(req, res, parsedUrl)
    }
})

How important is this feature to you?

I am a Fastify user. I have a little trouble integrating the two. Fastify uses a quite different concept from Express to route them, so I need a render function that can be called from any route.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions