Node.js

Node.js

Integrate Previewify with your Node.js application

View integration

You can integrate Previewify with any Node.js server side application. Here's an Express.js example serving a simple HTML template:

const express = require('express')
const { Previewify } = require('@flowframe/node-previewify')

const app = express()
const previewify = new Previewify({ apiToken: '<YOUR_API_TOKEN>' })

app.get('/', (request, response) => {
    const image = previewify.signedImageUrl({
        templateId: 732,
        fields: {
            'previewify:title': 'Hello from Node.js',
        },
    })

    return response.send(`
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8" />

                <meta http-equiv="X-UA-Compatible" content="IE=edge" />

                <meta name="viewport" content="width=device-width, initial-scale=1.0" />

                <title>Your Application</title>

                <meta property="og:image" content="${image}" />

                <meta name="twitter:image" content="${image}" />
            </head>

            <body>
                <h1>Hello from Node.js</h1>
            </body>
        </html>
    `)
})

app.listen(1337)