integration-astro-ssr
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "integration-astro-ssr" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1dd239f8e5123e53daaf901acdfc1f6fc1a8bf75213b2a45879dcf8bbbeaa575. Verify the upstream source and version against https://skills.sh/posthog/skills/integration-astro-ssr before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skills.sh
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Integrate PostHog into server-side rendered (SSR) Astro applications that use API routes to collect and analyze event data in SSR scenarios.
Introduction source: third_party · posthog · 1.0.0 Reference
SkillPi interpretation
- Tasks
- PostHog integration for server-rendered Astro applications with API routes
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Not specified in the source documentation.
- Software, accounts and paid services
- Not specified in the source documentation.
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: integration-astro-ssr
description: PostHog integration for server-rendered Astro applications with API routes
metadata:
author: PostHog
version: 1.9.4PostHog integration for Astro (SSR)
This skill helps you add PostHog analytics to Astro (SSR) applications.
Workflow
Follow these steps in order to complete the integration:
basic-integration-1.0-begin.md- PostHog Setup - Begin ← Start herebasic-integration-1.1-edit.md- PostHog Setup - Editbasic-integration-1.2-revise.md- PostHog Setup - Revisebasic-integration-1.3-conclude.md- PostHog Setup - Conclusion
Reference files
references/EXAMPLE.md- Astro (SSR) example project codereferences/astro.md- Astro - docsreferences/identify-users.md- Identify users - docsreferences/basic-integration-1.0-begin.md- PostHog setup - beginreferences/basic-integration-1.1-edit.md- PostHog setup - editreferences/basic-integration-1.2-revise.md- PostHog setup - revisereferences/basic-integration-1.3-conclude.md- PostHog setup - conclusion
The example project shows the target implementation pattern. Consult the documentation for API details.
Key principles
- Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
- Minimal changes: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
- Match the example: Your implementation should follow the example project's patterns as closely as possible.
Framework guidelines
- Always use the is:inline directive on PostHog script tags to prevent Astro from processing them and causing TypeScript errors
- Use PUBLIC_ prefix for client-side environment variables in Astro (e.g., PUBLIC_POSTHOG_PROJECT_TOKEN)
- Create a posthog.astro component in src/components/ for reusable initialization across pages
- Import the PostHog component in a Layout and wrap all pages with that layout
- Use posthog-node in API routes under src/pages/api/ for server-side event tracking
- Store the posthog-node client instance in a singleton pattern (src/lib/posthog-server.ts) to avoid creating multiple clients
- Pass the client session ID to server via X-PostHog-Session-Id header for unified session tracking
Identifying users
Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to maintain correlation.
Error tracking
Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 为 Astro SSR 应用提供 PostHog 集成方案,解决前端框架与分析工具对接的实际开发需求
- 适用于明确的技术栈场景,具有广泛开发者受众
Highlights
- 触发描述清晰,明确限定于 'server-rendered Astro applications with API routes',边界合理
Areas to improve
-
缺少端到端完整示例 Reported severity: Minor
工作流依赖多个外部文件,但未提供可直接运行的完整示例代码
Recommendation: 在 SKILL.md 中补充一个最小可运行示例,展示核心集成流程
-
未明确出口条件 Reported severity: Minor
未说明集成完成后的验证标准或成功标志
Recommendation: 添加 '验证集成是否成功' 的检查清单或测试方法
Highlights
- 工作流步骤清晰,引用文件组织良好
- 关键原则和框架指南实用性强
Areas to improve
-
主要异常未处理 Reported severity: Major
未覆盖网络错误、初始化失败、环境变量缺失等关键异常场景
Recommendation: 添加错误处理建议和 fallback 机制说明
Highlights
- 工具来源明确,参数建议合理(环境变量、singleton 模式)
- 提供了可复用的组件和布局集成方案
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Not specified in the source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.