{"id":13671379,"url":"https://github.com/dozjs/doz-ssr","last_synced_at":"2025-07-27T02:32:07.673Z","repository":{"id":56187159,"uuid":"137079927","full_name":"dozjs/doz-ssr","owner":"dozjs","description":"DOZ server-side rendering","archived":false,"fork":false,"pushed_at":"2021-01-08T11:39:11.000Z","size":1013,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T09:43:40.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dozjs.png","metadata":{"files":{"readme":"README.hbs","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-12T14:00:25.000Z","updated_at":"2022-08-09T15:54:06.000Z","dependencies_parsed_at":"2022-08-15T14:20:24.641Z","dependency_job_id":null,"html_url":"https://github.com/dozjs/doz-ssr","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozjs%2Fdoz-ssr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozjs%2Fdoz-ssr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozjs%2Fdoz-ssr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dozjs%2Fdoz-ssr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dozjs","download_url":"https://codeload.github.com/dozjs/doz-ssr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227750194,"owners_count":17814129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:07.991Z","updated_at":"2024-12-02T15:14:52.982Z","avatar_url":"https://github.com/dozjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# doz-ssr\nDOZ server-side rendering\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" title=\"License: MIT\"/\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/Node.js-%3E%3D10.x.x-green.svg\" title=\"Node.js version\"/\u003e\n\n## Installation\n\n```\nnpm install doz-ssr\n```\n\n## Example with Koa\n\n#### server.js\n\n```js\nconst Koa = require('koa');\nconst serve = require('koa-static');\nconst body = require('koa-body');\nconst DozSSR = require('doz-ssr');\n\nconst dozSSR = new DozSSR('./dist/index.html');\n\nnew Koa()\n    .use(serve('./public', {index: false}))\n    .use(body())\n    .use(async ctx =\u003e {\n        const [content] = await dozSSR.render(ctx.url, {\n            baseUrl: ctx.protocol + '://' + ctx.host\n        });\n        ctx.body = content;\n    })\n    .listen(3000);\n```\n\n#### bundle.js\n\n**IMPORTANT**, since 2.0.0 it's necessary to call `window.SSR.ready()` inside your Doz app\n\n```js\nnew Doz({\n    root: '#app',\n    template(h) {\n        return h`\n            \u003cdiv class=\"container\"\u003e\u003c/div\u003e\n        `\n    },\n    onMount() {\n        if (window.SSR)\n            window.SSR.ready();\n    }\n});\n```\n\n#### index.html\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003ctitle\u003eMyApp\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cdiv id=\"app\"\u003e\u003c/div\u003e\n    \u003cscript id=\"bundle\" src=\"/bundle.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## API\n\n{{\u003emain}}\n\n## PLUGIN\n\nThere is a plugin that adds a method and a directive:\n\n```js\nimport ssrPlugin from 'doz-ssr/plugin'\n\nDoz.use(ssrPlugin);\n\n// If you call isSSR() method inside your app you can check if it is in server environment\nDoz.component('my-component', function(h){\n    return h`\n        \u003cdiv\u003eis server? ${this.isSSR()}\u003c/div\u003e\n    `\n})\n\n// If you want exclude (not visible) a component or part of html you can use the directive `d-ssr-invisible`\nDoz.component('my-component', function(h){\n    return h`\n        \u003cdiv\u003e\n            hello my friend\n            \u003c!-- on server side this will be not shown --\u003e\n            \u003cdiv d-ssr-invisible\u003ewow!\u003c/div\u003e\n        \u003c/div\u003e\n    `\n})\n```\n\n## Changelog\nYou can view the changelog \u003ca target=\"_blank\" href=\"https://github.com/dozjs/doz-ssr/blob/master/CHANGELOG.md\"\u003ehere\u003c/a\u003e\n\n## License\ndoz-ssr is open-sourced software licensed under the \u003ca target=\"_blank\" href=\"http://opensource.org/licenses/MIT\"\u003eMIT license\u003c/a\u003e\n\n## Author\n\u003ca target=\"_blank\" href=\"http://rica.li\"\u003eFabio Ricali\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdozjs%2Fdoz-ssr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdozjs%2Fdoz-ssr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdozjs%2Fdoz-ssr/lists"}